Search in sources :

Example 6 with MainActivity

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

the class PlaylistFragment method onCreateView.

public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View root = inflater.inflate(R.layout.fragment_playlist, container, false);
    textTitle = root.findViewById(R.id.playlist_title);
    textVideoCount = root.findViewById(R.id.playlist_video_count);
    playlistItemsLoading = root.findViewById(R.id.playlist_items_loading);
    visibilityIcon = root.findViewById(R.id.playlist_icon);
    playlistList = root.findViewById(R.id.playlist_items);
    LinearLayoutManager llm = new LinearLayoutManager(getContext());
    playlistList.setLayoutManager(llm);
    playButton = root.findViewById(R.id.playlist_play);
    playButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            Context context = getContext();
            if (currentCollection != null && context instanceof MainActivity) {
                MainActivity activity = (MainActivity) context;
                // openPrivatePlaylist also works for public (published) collections, because we've already  loaded and resolved
                // so we use it, because it's faster, instead of  having to re-resolve
                activity.openPrivatePlaylist(currentCollection);
            }
        }
    });
    return root;
}
Also used : Context(android.content.Context) MainActivity(com.odysee.app.MainActivity) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) TextView(android.widget.TextView)

Example 7 with MainActivity

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

the class SettingsFragment method onResume.

@Override
public void onResume() {
    super.onResume();
    Context context = getContext();
    if (context instanceof MainActivity) {
        PreferenceManager.getDefaultSharedPreferences(context).registerOnSharedPreferenceChangeListener(this);
        MainActivity activity = (MainActivity) context;
        MainActivity.suspendGlobalPlayer(context);
        LbryAnalytics.setCurrentScreen(activity, "Settings", "Settings");
    }
}
Also used : Context(android.content.Context) MainActivity(com.odysee.app.MainActivity)

Example 8 with MainActivity

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

the class PublishFormFragment method initUi.

private void initUi() {
    Context context = getContext();
    languageSpinner.setAdapter(new LanguageSpinnerAdapter(context, R.layout.spinner_item_generic));
    licenseSpinner.setAdapter(new LicenseSpinnerAdapter(context, R.layout.spinner_item_generic));
    licenseSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> adapterView, View view, int position, long l) {
            License license = (License) adapterView.getAdapter().getItem(position);
            boolean otherLicense = Arrays.asList(Predefined.LICENSE_COPYRIGHTED.toLowerCase(), Predefined.LICENSE_OTHER.toLowerCase()).contains(license.getName().toLowerCase());
            Helper.setViewVisibility(layoutOtherLicenseDescription, otherLicense ? View.VISIBLE : View.GONE);
            if (!otherLicense) {
                inputOtherLicenseDescription.setText(null);
            }
        }

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

        @Override
        public void onClick(View view) {
            if (!editMode) {
                inputAddress.setText(Helper.generateUrl());
            }
        }
    });
    switchPrice.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
            Helper.setViewVisibility(textNoPrice, checked ? View.GONE : View.VISIBLE);
            Helper.setViewVisibility(layoutPrice, checked ? View.VISIBLE : View.GONE);
        }
    });
    inputAddress.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) {
            String value = Helper.getValue(charSequence);
            boolean invalid = !Helper.isNullOrEmpty(value) && !LbryUri.isNameValid(value);
            Helper.setViewVisibility(textInlineAddressInvalid, invalid ? View.VISIBLE : View.INVISIBLE);
        }

        @Override
        public void afterTextChanged(Editable editable) {
        }
    });
    inputDeposit.setOnFocusChangeListener(new View.OnFocusChangeListener() {

        @Override
        public void onFocusChange(View view, boolean hasFocus) {
            Helper.setViewVisibility(inlineDepositBalanceContainer, hasFocus ? View.VISIBLE : View.GONE);
        }
    });
    linkShowExtraFields.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            if (layoutExtraFields.getVisibility() != View.VISIBLE) {
                layoutExtraFields.setVisibility(View.VISIBLE);
                linkShowExtraFields.setText(R.string.hide_extra_fields);
                scrollView.post(new Runnable() {

                    @Override
                    public void run() {
                        scrollView.fullScroll(NestedScrollView.FOCUS_DOWN);
                    }
                });
            } else {
                layoutExtraFields.setVisibility(View.GONE);
                linkShowExtraFields.setText(R.string.show_extra_fields);
            }
        }
    });
    mediaContainer.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            checkStoragePermissionAndLaunchFilePicker();
        }
    });
    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() && !claim.isPlaceholderAnonymous()) {
                    if (!fetchingChannels) {
                        showChannelCreator();
                    }
                }
            }
        }

        @Override
        public void onNothingSelected(AdapterView<?> adapterView) {
        }
    });
    inputTagFilter.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) {
            String value = Helper.getValue(charSequence);
            setFilter(value);
        }

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

        @Override
        public void onClick(View view) {
            if (transcodeInProgress) {
                // show alert confirming the user is sure, and then cancel
                FFmpeg.cancel();
                transcodeInProgress = false;
            }
            Context context = getContext();
            if (context instanceof MainActivity) {
                ((MainActivity) context).onBackPressed();
            }
        }
    });
    buttonPublish.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            if (uploading) {
                Snackbar.make(view, R.string.publish_thumbnail_in_progress, Snackbar.LENGTH_LONG).show();
                return;
            } else if (Helper.isNullOrEmpty(uploadedThumbnailUrl)) {
                showError(getString(R.string.publish_no_thumbnail));
                return;
            }
            if (transcodeInProgress) {
                Snackbar.make(view, R.string.optimization_in_progress, Snackbar.LENGTH_LONG).show();
                return;
            }
            // check minimum deposit
            String depositString = Helper.getValue(inputDeposit.getText());
            double depositAmount = 0;
            try {
                depositAmount = Double.valueOf(depositString);
            } catch (NumberFormatException ex) {
                // pass
                showError(getString(R.string.please_enter_valid_deposit));
                return;
            }
            if (depositAmount < Helper.MIN_DEPOSIT) {
                String error = getResources().getQuantityString(R.plurals.min_deposit_required, depositAmount == 1 ? 1 : 2, String.valueOf(Helper.MIN_DEPOSIT));
                showError(error);
                return;
            }
            if (Lbry.getAvailableBalance() < depositAmount) {
                showError(getString(R.string.deposit_more_than_balance));
                return;
            }
            String priceString = Helper.getValue(inputPrice.getText());
            double priceAmount = Helper.parseDouble(priceString, 0);
            if (switchPrice.isChecked() && priceAmount == 0) {
                showError(getString(R.string.price_amount_not_set));
                return;
            }
            Claim claim = buildPublishClaim();
            if (validatePublishClaim(claim)) {
                publishClaim(claim);
            }
        }
    });
    channelSpinnerAdapter = new InlineChannelSpinnerAdapter(getContext(), R.layout.spinner_item_channel, new ArrayList<>());
    channelSpinnerAdapter.addPlaceholder(false);
}
Also used : License(com.odysee.app.model.License) MainActivity(com.odysee.app.MainActivity) LicenseSpinnerAdapter(com.odysee.app.adapter.LicenseSpinnerAdapter) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) Context(android.content.Context) InlineChannelSpinnerAdapter(com.odysee.app.adapter.InlineChannelSpinnerAdapter) NestedScrollView(androidx.core.widget.NestedScrollView) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) RecyclerView(androidx.recyclerview.widget.RecyclerView) CardView(androidx.cardview.widget.CardView) TextView(android.widget.TextView) LanguageSpinnerAdapter(com.odysee.app.adapter.LanguageSpinnerAdapter) AdapterView(android.widget.AdapterView) JSONObject(org.json.JSONObject) CompoundButton(android.widget.CompoundButton) Claim(com.odysee.app.model.Claim)

Example 9 with MainActivity

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

the class PublishFormFragment method onResume.

public void onResume() {
    super.onResume();
    checkParams();
    checkRewardsDriver();
    updateFieldsFromCurrentClaim();
    fetchChannels();
    if (currentClaim == null && (currentGalleryItem != null || !Helper.isNullOrEmpty(currentFilePath))) {
        // load file information
        checkPublishFile();
    }
    Context context = getContext();
    Helper.setWunderbarValue(null, context);
    if (context instanceof MainActivity) {
        MainActivity activity = (MainActivity) context;
        LbryAnalytics.setCurrentScreen(activity, "Channel Form", "ChannelForm");
        activity.addStoragePermissionListener(this);
        if (editMode) {
            activity.setActionBarTitle(R.string.edit_content);
        }
    }
    String filterText = Helper.getValue(inputTagFilter.getText());
    updateSuggestedTags(filterText, SUGGESTED_LIMIT, true);
}
Also used : Context(android.content.Context) MainActivity(com.odysee.app.MainActivity)

Example 10 with MainActivity

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

the class PublishFormFragment method onStop.

@Override
public void onStop() {
    Context context = getContext();
    if (context instanceof MainActivity) {
        MainActivity activity = (MainActivity) getContext();
        if (!MainActivity.startingFilePickerActivity) {
            activity.removeWalletBalanceListener(this);
            activity.removeFilePickerListener(this);
            if (transcodeInProgress) {
                FFmpeg.cancel();
            }
        }
    }
    super.onStop();
}
Also used : Context(android.content.Context) MainActivity(com.odysee.app.MainActivity)

Aggregations

MainActivity (com.odysee.app.MainActivity)138 Context (android.content.Context)119 Claim (com.odysee.app.model.Claim)39 View (android.view.View)31 TextView (android.widget.TextView)30 RecyclerView (androidx.recyclerview.widget.RecyclerView)26 AttributeProviderContext (org.commonmark.renderer.html.AttributeProviderContext)25 ArrayList (java.util.ArrayList)21 TrackSelectionOverride (com.google.android.exoplayer2.trackselection.TrackSelectionOverrides.TrackSelectionOverride)19 ImageView (android.widget.ImageView)18 SuppressLint (android.annotation.SuppressLint)15 AdapterView (android.widget.AdapterView)14 NestedScrollView (androidx.core.widget.NestedScrollView)14 JSONException (org.json.JSONException)13 JSONObject (org.json.JSONObject)13 SolidIconView (com.odysee.app.ui.controls.SolidIconView)12 HashMap (java.util.HashMap)12 ClaimListAdapter (com.odysee.app.adapter.ClaimListAdapter)11 ApiCallException (com.odysee.app.exceptions.ApiCallException)11 WebView (android.webkit.WebView)10