Search in sources :

Example 86 with MainActivity

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

the class PublishesFragment method onEnterSelectionMode.

public void onEnterSelectionMode() {
    Context context = getContext();
    if (context instanceof MainActivity) {
        MainActivity activity = (MainActivity) context;
        activity.startSupportActionMode(this);
    }
}
Also used : Context(android.content.Context) MainActivity(com.odysee.app.MainActivity)

Example 87 with MainActivity

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

the class Lbryio method newInstall.

public static void newInstall(Context context) {
    String appVersion = "";
    if (context != null) {
        try {
            PackageManager manager = context.getPackageManager();
            PackageInfo info = manager.getPackageInfo(context.getPackageName(), PackageManager.GET_ACTIVITIES);
            appVersion = info.versionName;
        } catch (PackageManager.NameNotFoundException ex) {
        }
    }
    Map<String, String> options = new HashMap<>();
    if (context instanceof MainActivity) {
        String firebaseToken = ((MainActivity) context).getFirebaseMessagingToken();
        if (!Helper.isNullOrEmpty(firebaseToken)) {
            options.put("firebase_token", firebaseToken);
        }
    }
    options.put("app_version", appVersion);
    options.put("app_id", Lbry.INSTALLATION_ID);
    options.put("node_id", "");
    options.put("operating_system", "android");
    options.put("platform", String.format("Android %s (API %d)", Build.VERSION.RELEASE, Build.VERSION.SDK_INT));
    options.put("domain", "odysee.com");
    try {
        JSONObject response = (JSONObject) parseResponse(call("install", "new", options, Helper.METHOD_POST, context));
    } catch (LbryioRequestException | LbryioResponseException | ClassCastException ex) {
        // pass
        Log.e(TAG, String.format("install/new failed: %s", ex.getMessage()), ex);
    }
}
Also used : PackageManager(android.content.pm.PackageManager) JSONObject(org.json.JSONObject) HashMap(java.util.HashMap) PackageInfo(android.content.pm.PackageInfo) LbryioRequestException(com.odysee.app.exceptions.LbryioRequestException) MainActivity(com.odysee.app.MainActivity) LbryioResponseException(com.odysee.app.exceptions.LbryioResponseException)

Example 88 with MainActivity

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

the class PublishFragment method loadGalleryItems.

private void loadGalleryItems() {
    Context context = getContext();
    Helper.setViewVisibility(noVideosLoaded, View.GONE);
    LoadGalleryItemsTask task = new LoadGalleryItemsTask(loading, context, new LoadGalleryItemsTask.LoadGalleryHandler() {

        @Override
        public void onItemLoaded(GalleryItem item) {
            if (context != null) {
                if (adapter == null) {
                    adapter = new GalleryGridAdapter(Arrays.asList(item), context);
                    adapter.setListener(new GalleryGridAdapter.GalleryItemClickListener() {

                        @Override
                        public void onGalleryItemClicked(GalleryItem item) {
                            Context context = getContext();
                            if (context instanceof MainActivity) {
                                Map<String, Object> params = new HashMap<>();
                                params.put("galleryItem", item);
                                params.put("suggestedUrl", getSuggestedPublishUrl());
                            // ((MainActivity) context).openFragment(PublishFormFragment.class, true, NavMenuItem.ID_ITEM_NEW_PUBLISH, params);
                            }
                        }
                    });
                } else {
                    adapter.addItem(item);
                }
                if (galleryGrid.getAdapter() == null) {
                    galleryGrid.setAdapter(adapter);
                }
                Helper.setViewVisibility(loading, adapter == null || adapter.getItemCount() == 0 ? View.VISIBLE : View.GONE);
            }
        }

        @Override
        public void onAllItemsLoaded(List<GalleryItem> items) {
            if (context != null) {
                if (adapter == null) {
                    adapter = new GalleryGridAdapter(items, context);
                } else {
                    adapter.addItems(items);
                }
                if (galleryGrid.getAdapter() == null) {
                    galleryGrid.setAdapter(adapter);
                }
            }
            checkNoVideosLoaded();
        }
    });
    task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
Also used : Context(android.content.Context) HashMap(java.util.HashMap) LoadGalleryItemsTask(com.odysee.app.tasks.localdata.LoadGalleryItemsTask) MainActivity(com.odysee.app.MainActivity) GalleryItem(com.odysee.app.model.GalleryItem) GalleryGridAdapter(com.odysee.app.adapter.GalleryGridAdapter)

Example 89 with MainActivity

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

the class PublishFragment method launchFilePicker.

private void launchFilePicker() {
    Context context = getContext();
    if (context instanceof MainActivity) {
        MainActivity.startingFilePickerActivity = true;
        Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
        intent.setType("*/*");
        ((MainActivity) context).startActivityForResult(Intent.createChooser(intent, getString(R.string.upload_file)), MainActivity.REQUEST_FILE_PICKER);
    }
}
Also used : Context(android.content.Context) Intent(android.content.Intent) MainActivity(com.odysee.app.MainActivity)

Example 90 with MainActivity

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

the class PublishFragment method takePhoto.

private void takePhoto() {
    Context context = getContext();
    if (context instanceof MainActivity) {
        takePhotoPending = false;
        ((MainActivity) context).requestTakePhoto();
    }
}
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