private void loadError(VolleyError error) { progressWheel.setVisibility(View.GONE); footerProgressWheel.setVisibility(View.GONE); if (Utils.isNetworkError(error) && "".equals(nextPageToken)) { Button btnRetry = (Button) rootView.findViewById(R.id.btn_retry); btnRetry.setOnClickListener(this); btnRetry.setVisibility(View.VISIBLE); } else { Utils.handleError(getActivity(), error); } }
private void initViews() { nextPageToken = ""; if (recyclerView == null) { recyclerView = (RecyclerView) rootView.findViewById(R.id.recyclerview); progressWheel = rootView.findViewById(R.id.progress_bar); footerProgressWheel = rootView.findViewById(R.id.footer_progress_bar); LinearLayoutManager linearLayoutManager = new LinearLayoutManager(recyclerView.getContext()); recyclerView.setLayoutManager(linearLayoutManager); recyclerView.addOnScrollListener( new EndlessScrollVideosListener(linearLayoutManager) { @Override public void onLoadMore(int currentPage) { MyLog.e("Current Page: (DailyMotion) " + currentPage); if (nextPageToken == null) { MyLog.e("End of loading more daily motion video"); } else { loadVideoContent(); } } }); } loadVideoContent(); navIndex = TTApplication.navIndex; Utils.sendTracker(Constants.SCREEN_DAILYMOTION_SEARCH_LIST); }
@Override public void onDailyMotionVideoItemSelected(DMItem video) { Intent intent = new Intent(getActivity(), PlayerDMActivity.class); intent.putExtra(Constants.BUNDLE_VIDEO, video); startActivityForResult(intent, Constants.REQUEST_VIDEO_DETAIL); Utils.animateActivity(getActivity(), "next"); }
@Override public void onBindViewHolder(ViewHolder viewHolder, int i) { YTItem item = mItems.get(i); // Utils.displayImage(activity, item.getSnippet().getThumbnails().getMediumImage().getUrl(), // R.drawable.image, viewHolder.imgThumbnail); Utils.displayImage( activity, item.getSnippet().getThumbnails().getMediumImage().getUrl(), viewHolder.imgThumbnail); viewHolder.txtTitle.setText(item.getSnippet().getTitle()); viewHolder.txtChannelTitle.setText(item.getSnippet().getChannelTitle()); viewHolder.txtAgeAndViews.setText( Utils.calculateAge(item.getSnippet().getPublishedAt()) + " . " + Utils.calculateViewCount(item.getStatistics().getViewCount()) + " views"); viewHolder.txtDuration.setText(Utils.calculateDuration(item.getContentDetails().getDuration())); viewHolder.setVideoItem(item); // MyLog.e(Utils.calculateDuration(item.getContentDetails().getDuration())); }
public void execute(String token, String query) { try { String url = Config.getSearchYouTubeVideosUrl(token, query); MyLog.e("Generated Url: " + url); TTGsonRequest<YTModel> nNacresGsonRequest = new TTGsonRequest<YTModel>(activity, url, null, this, YTModel.class); nNacresGsonRequest.setTaskId(this); TTVolleyManager.addToQueue(nNacresGsonRequest, false); } catch (UnsupportedEncodingException e) { e.printStackTrace(); Utils.showErrorToast(activity, Constants.ERROR_UNSUPPORTED_CHARACTER, Toast.LENGTH_SHORT); return; } catch (Exception e) { e.printStackTrace(); onErrorResponse(null, new ParseError()); } }