Search in sources :

Example 1 with NavigationHelper

use of com.zype.android.ui.NavigationHelper in project zype-android by zype.

the class GalleryRowItemsAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(final GalleryRowItemsAdapter.ViewHolder holder, int position) {
    holder.item = items.get(position);
    updateTitle(holder);
    updateInlineTitle(holder);
    loadThumbnail(holder);
    updateLockIcon(holder);
    holder.view.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            NavigationHelper navigationHelper = NavigationHelper.getInstance(holder.view.getContext());
            if (holder.item instanceof Video) {
                Video video = (Video) holder.item;
                navigationHelper.handleVideoClick((Activity) holder.view.getContext(), video, playlistId, false);
            } else if (holder.item instanceof Playlist) {
                Playlist playlist = (Playlist) holder.item;
                navigationHelper.handlePlaylistClick((Activity) holder.view.getContext(), playlist);
            }
        }
    });
}
Also used : Playlist(com.zype.android.Db.Entity.Playlist) NavigationHelper(com.zype.android.ui.NavigationHelper) Video(com.zype.android.Db.Entity.Video) Activity(android.app.Activity) ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) TextView(android.widget.TextView)

Example 2 with NavigationHelper

use of com.zype.android.ui.NavigationHelper in project zype-android by zype.

the class SearchActivity method onItemClick.

// //////////
// UI
// 
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    Logger.d("onItemClick()");
    VideosCursorAdapter.VideosViewHolder holder = (VideosCursorAdapter.VideosViewHolder) view.getTag();
    NavigationHelper navigationHelper = NavigationHelper.getInstance(this);
    if (AuthHelper.isVideoUnlocked(this, holder.videoId, null)) {
        navigationHelper.switchToVideoDetailsScreen(this, holder.videoId, null, false);
    } else {
        navigationHelper.handleNotAuthorizedVideo(this, holder.videoId, null);
    }
}
Also used : NavigationHelper(com.zype.android.ui.NavigationHelper) VideosCursorAdapter(com.zype.android.ui.main.fragments.videos.VideosCursorAdapter)

Example 3 with NavigationHelper

use of com.zype.android.ui.NavigationHelper in project zype-android by zype.

the class ActionBuyVideoFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    binding = FragmentActionBuyVideoBinding.inflate(inflater, container, false);
    final NavigationHelper navigationHelper = NavigationHelper.getInstance(getActivity());
    binding.actionLayout.setOnClickListener(v -> {
        if (AuthHelper.isLoggedIn()) {
            showPurchaseScreen();
        } else {
            navigationHelper.switchToLoginScreen(this);
        }
    });
    return binding.getRoot();
}
Also used : NavigationHelper(com.zype.android.ui.NavigationHelper)

Example 4 with NavigationHelper

use of com.zype.android.ui.NavigationHelper in project zype-android by zype.

the class LibraryFragment method onActivityCreated.

@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    model = ViewModelProviders.of(this).get(LibraryViewModel.class);
    model.getVideos().observe(this, observerVideos);
    model.getSelectedVideo().observe(this, video -> {
        if (video != null) {
            NavigationHelper navigationHelper = NavigationHelper.getInstance(getActivity());
            navigationHelper.handleVideoClick(getActivity(), video, null, false);
            model.onSelectedVideoProcessed();
        }
    });
    adapter.setVideoListener((video) -> {
        model.onVideoClicked(video);
    });
    adapter.setPopupMenuListener((action, video) -> {
        model.handleVideoAction(action, video, success -> {
            if (success) {
                model.retrieveVideos(false);
            } else {
                NavigationHelper.getInstance(getActivity()).switchToLoginScreen(getActivity());
            }
        });
    });
}
Also used : NavigationHelper(com.zype.android.ui.NavigationHelper)

Example 5 with NavigationHelper

use of com.zype.android.ui.NavigationHelper in project zype-android by zype.

the class SearchActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_search_v2);
    Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    listVideos = findViewById(R.id.listVideos);
    adapter = new VideosAdapter(null);
    listVideos.setAdapter(adapter);
    progressBar = findViewById(R.id.progress);
    viewSearch = findViewById(R.id.viewSearch);
    viewSearch.setOnQueryTextListener(new SearchView.OnQueryTextListener() {

        @Override
        public boolean onQueryTextSubmit(String query) {
            if (!TextUtils.isEmpty(query)) {
                model.search(query, ZypeConfiguration.getRootPlaylistId(SearchActivity.this));
            }
            return false;
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            return false;
        }
    });
    viewSearch.setOnCloseListener(new SearchView.OnCloseListener() {

        @Override
        public boolean onClose() {
            hideProgress();
            model.clearSearchResults();
            showEmptyQuery(true);
            return false;
        }
    });
    textEmptyResult = findViewById(R.id.textEmptyResult);
    textErrorEmptyQuery = findViewById(R.id.textErrorEmptyQuery);
    viewSearch.setQuery("", false);
    viewSearch.setIconified(false);
    viewSearch.setFocusable(false);
    viewSearch.clearFocus();
    model = ViewModelProviders.of(this).get(SearchViewModel.class);
    model.getVideos().observe(this, createVideosObserver());
    model.getSelectedVideo().observe(this, video -> {
        if (video != null) {
            NavigationHelper navigationHelper = NavigationHelper.getInstance(this);
            navigationHelper.handleVideoClick(this, video, null, false);
            model.onSelectedVideoProcessed();
        }
    });
    adapter.setVideoListener((video) -> {
        model.onVideoClicked(video);
    });
    adapter.setPopupMenuListener((action, video) -> {
        model.handleVideoAction(action, video, success -> {
            if (success) {
                model.refresh();
            } else {
                NavigationHelper.getInstance(SearchActivity.this).switchToLoginScreen(SearchActivity.this);
            }
        });
    });
}
Also used : SearchView(androidx.appcompat.widget.SearchView) NavigationHelper(com.zype.android.ui.NavigationHelper) Toolbar(androidx.appcompat.widget.Toolbar) VideosAdapter(com.zype.android.ui.v2.videos.VideosAdapter)

Aggregations

NavigationHelper (com.zype.android.ui.NavigationHelper)13 Video (com.zype.android.Db.Entity.Video)4 View (android.view.View)3 ImageView (android.widget.ImageView)2 TextView (android.widget.TextView)2 Playlist (com.zype.android.Db.Entity.Playlist)2 VideosCursorAdapter (com.zype.android.ui.main.fragments.videos.VideosCursorAdapter)2 Activity (android.app.Activity)1 Button (android.widget.Button)1 Nullable (androidx.annotation.Nullable)1 SearchView (androidx.appcompat.widget.SearchView)1 Toolbar (androidx.appcompat.widget.Toolbar)1 Observer (androidx.lifecycle.Observer)1 RecyclerView (androidx.recyclerview.widget.RecyclerView)1 Purchase (com.android.billingclient.api.Purchase)1 Subscription (com.zype.android.Billing.Subscription)1 VideosAdapter (com.zype.android.ui.v2.videos.VideosAdapter)1 ConsumerFavoriteVideo (com.zype.android.webapi.model.consumers.ConsumerFavoriteVideo)1