- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个视频流应用程序,可以与 ExoPlayer2 配合使用,但我的用户现在希望我添加一个在外部播放器中播放视频的选项,因此我试图编写一个 Intent ,但似乎无法做到。
我的适配器必须从其中获取链接:
public class ServerApater extends RecyclerView.Adapter<ServerApater.OriginalViewHolder> {
private List<CommonModels> items = new ArrayList<>();
private Context ctx;
private ServerApater.OnItemClickListener mOnItemClickListener;
private ServerApater.OriginalViewHolder viewHolder;
public interface OnItemClickListener {
void onItemClick(View view, CommonModels obj, int position, OriginalViewHolder holder);
}
public void setOnItemClickListener(ServerApater.OnItemClickListener mItemClickListener) {
this.mOnItemClickListener = mItemClickListener;
}
public ServerApater(Context context, List<CommonModels> items) {
this.items = items;
ctx = context;
}
@Override
public ServerApater.OriginalViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
ServerApater.OriginalViewHolder vh;
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.card_server, parent, false);
vh = new ServerApater.OriginalViewHolder(v);
return vh;
}
@Override
public void onBindViewHolder(final ServerApater.OriginalViewHolder holder, final int position) {
CommonModels obj = items.get(position);
holder.name.setText(obj.getTitle());
if (position==0){
viewHolder=holder;
new DetailsActivity().iniMoviePlayer(obj.getStremURL(),obj.getServerType(),ctx);
holder.name.setTextColor(ctx.getResources().getColor(R.color.colorPrimary));
}
holder.cardView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (mOnItemClickListener != null) {
mOnItemClickListener.onItemClick(v, items.get(position), position,holder);
}
}
});
}
@Override
public int getItemCount() {
return items.size();
}
public class OriginalViewHolder extends RecyclerView.ViewHolder {
public TextView name;
public CardView cardView;
public OriginalViewHolder(View v) {
super(v);
name = v.findViewById(R.id.name);
cardView=v.findViewById(R.id.card_view_home);
}
}
public void chanColor(ServerApater.OriginalViewHolder holder,int pos){
if (pos!=0){
viewHolder.name.setTextColor(ctx.getResources().getColor(R.color.grey_60));
}
if (holder!=null){
holder.name.setTextColor(ctx.getResources().getColor(R.color.grey_60));
}
}
}
现在的问题是,我不知道该怎么做。我的 Intent 中的“obj.getStremURL()”表示“无法解析符号‘obj’”
感谢任何帮助。
编辑:
我的 Activity :
public class DetailsActivity extends AppCompatActivity {
int i = 0;
private TextView tvName,tvDirector,tvRelease,tvCast,tvDes,tvGenre,tvRelated;
private RecyclerView rvDirector,rvServer,rvRelated,rvComment;
public static RelativeLayout lPlay;
private EpisodeAdapter episodeAdapter;
private HomePageAdapter relatedAdapter;
private LiveTvHomeAdapter relatedTvAdapter;
public static LinearLayout llBottom,llBottomParent,llcomment;
private SwipeRefreshLayout swipeRefreshLayout;
private String type="",id="";
private ImageView imgAddFav;
public static ImageView imgBack;
public static ImageView imgPlayer;
private String V_URL = "";
public static WebView webView;
public static ProgressBar progressBar;
private boolean isFav = false;
private ShimmerFrameLayout shimmerFrameLayout;
private Button btnComment;
private EditText etComment;
private CommentsAdapter commentsAdapter;
private String commentURl;
private AdView adView;
private InterstitialAd mInterstitialAd;
public static SimpleExoPlayer player;
public static PlayerView simpleExoPlayerView;
public static SubtitleView subtitleView;
public static ImageView imgFull;
public static ImageView imgfit;
public static boolean isPlaying,isFullScr;
public static View playerLayout;
private int playerHeight;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_details);
imgPlayer=findViewById(R.id.img_player);
shimmerFrameLayout.startShimmer();
playerHeight = lPlay.getLayoutParams().height;
progressBar.setMax(100); // 100 maximum value for the progress value
progressBar.setProgress(50);
imgBack.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
imgPlayer.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse(obj.getStremURL()), "video/*");
startActivity(Intent.createChooser(intent, "Complete action using"));
}
});
type = getIntent().getStringExtra("vType");
id = getIntent().getStringExtra("id");
final SharedPreferences preferences=getSharedPreferences("user",MODE_PRIVATE);
if (preferences.getBoolean("status",false)){
imgAddFav.setVisibility(VISIBLE);
}else {
imgAddFav.setVisibility(GONE);
}
imgFull.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (isFullScr){
isFullScr=false;
showSystemUI();
llBottomParent.setVisibility(VISIBLE);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
lPlay.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, playerHeight));
imgfit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
simpleExoPlayerView.setResizeMode(AspectRatioFrameLayout.RESIZE_MODE_FIT);
}
});
}else {
hideSystemUI();
isFullScr=true;
llBottomParent.setVisibility(GONE);
lPlay.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT));
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
imgfit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
i++;
Runnable r = new Runnable() {
@Override
public void run() {
i = 0;
}
};
if (i == 1) {
//Single click
simpleExoPlayerView.setResizeMode(AspectRatioFrameLayout.RESIZE_MODE_FILL);
} else if (i == 2) {
//Double click
i = 0;
simpleExoPlayerView.setResizeMode(AspectRatioFrameLayout.RESIZE_MODE_ZOOM);
} else if (i == 3) {
// Triple Click
i = 0;
simpleExoPlayerView.setResizeMode(AspectRatioFrameLayout.RESIZE_MODE_FIT);
} else if (i == 4) {
// Fourth Click
i = 0;
simpleExoPlayerView.setResizeMode(AspectRatioFrameLayout.RESIZE_MODE_FILL);
}
}
});
}
}
});
imgAddFav.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String url = new ApiResources().getAddFav()+"&&user_id="+preferences.getString("id","0")+"&&videos_id="+id;
if (isFav){
String removeURL = new ApiResources().getRemoveFav()+"&&user_id="+preferences.getString("id","0")+"&&videos_id="+id;
removeFromFav(removeURL);
}else {
addToFav(url);
}
}
});
if (!isNetworkAvailable()){
new ToastMsg(DetailsActivity.this).toastIconError(getString(R.string.no_internet));
}
initGetData();
swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
initGetData();
}
});
}
private void initGetData(){
if (!type.equals("tv")){
//----related rv----------
relatedAdapter=new HomePageAdapter(this,listRelated);
rvRelated.setLayoutManager(new LinearLayoutManager(this,LinearLayoutManager.HORIZONTAL,false));
rvRelated.setHasFixedSize(true);
rvRelated.setAdapter(relatedAdapter);
if (type.equals("tvseries")){
rvRelated.removeAllViews();
listRelated.clear();
rvServer.removeAllViews();
listDirector.clear();
listEpisode.clear();
episodeAdapter=new EpisodeAdapter(this,listDirector);
rvServer.setLayoutManager(new LinearLayoutManager(this));
rvServer.setHasFixedSize(true);
rvServer.setAdapter(episodeAdapter);
getSeriesData(type,id);
}else {
rvServer.removeAllViews();
listDirector.clear();
rvRelated.removeAllViews();
listRelated.clear();
serverApater=new ServerApater(this,listDirector);
rvServer.setLayoutManager(new LinearLayoutManager(this,LinearLayoutManager.HORIZONTAL,false));
rvServer.setHasFixedSize(true);
rvServer.setAdapter(serverApater);
getData(type,id);
final ServerApater.OriginalViewHolder[] viewHolder = {null};
serverApater.setOnItemClickListener(new ServerApater.OnItemClickListener() {
@Override
public void onItemClick(View view, CommonModels obj, int position, ServerApater.OriginalViewHolder holder) {
iniMoviePlayer(obj.getStremURL(),obj.getServerType(),DetailsActivity.this);
serverApater.chanColor(viewHolder[0],position);
holder.name.setTextColor(getResources().getColor(R.color.colorPrimary));
viewHolder[0] =holder;
}
});
}
SharedPreferences sharedPreferences=getSharedPreferences("user",MODE_PRIVATE);
String url = new ApiResources().getFavStatusURl()+"&&user_id="+sharedPreferences.getString("id","0")+"&&videos_id="+id;
if (sharedPreferences.getBoolean("status",false)){
getFavStatus(url);
}
}else {
llcomment.setVisibility(GONE);
tvRelated.setText("All TV :");
rvServer.removeAllViews();
listDirector.clear();
rvRelated.removeAllViews();
listRelated.clear();
//----related rv----------
relatedTvAdapter=new LiveTvHomeAdapter(this,listRelated);
rvRelated.setLayoutManager(new LinearLayoutManager(this,LinearLayoutManager.HORIZONTAL,false));
rvRelated.setHasFixedSize(true);
rvRelated.setAdapter(relatedTvAdapter);
imgAddFav.setVisibility(GONE);
serverApater=new ServerApater(this,listDirector);
rvServer.setLayoutManager(new LinearLayoutManager(this,LinearLayoutManager.HORIZONTAL,false));
rvServer.setHasFixedSize(true);
rvServer.setAdapter(serverApater);
getTvData(type,id);
llBottom.setVisibility(GONE);
final ServerApater.OriginalViewHolder[] viewHolder = {null};
serverApater.setOnItemClickListener(new ServerApater.OnItemClickListener() {
@Override
public void onItemClick(View view, CommonModels obj, int position, ServerApater.OriginalViewHolder holder) {
iniMoviePlayer(obj.getStremURL(),obj.getServerType(),DetailsActivity.this);
serverApater.chanColor(viewHolder[0],position);
holder.name.setTextColor(getResources().getColor(R.color.colorPrimary));
viewHolder[0] =holder;
}
});
}
}
private void initWeb(String s){
if (isPlaying){
player.release();
}
progressBar.setVisibility(GONE);
webView.loadUrl(s);
webView.setVisibility(VISIBLE);
playerLayout.setVisibility(GONE);
}
public void iniMoviePlayer(String url,String type,Context context){
Log.e("vTYpe :: ",type);
if (type.equals("embed") || type.equals("vimeo") || type.equals("gdrive")){
initWeb(url);
}else {
initVideoPlayer(url,context,type);
}
}
public void initVideoPlayer(String url,Context context,String type){
progressBar.setVisibility(VISIBLE);
if (player!=null){
player.release();
}
webView.setVisibility(GONE);
playerLayout.setVisibility(VISIBLE);
BandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
TrackSelection.Factory videoTrackSelectionFactory = new
AdaptiveTrackSelection.Factory(bandwidthMeter);
TrackSelector trackSelector = new
DefaultTrackSelector(videoTrackSelectionFactory);
player = ExoPlayerFactory.newSimpleInstance(context, trackSelector);
player.setPlayWhenReady(true);
simpleExoPlayerView.setPlayer(player);
simpleExoPlayerView.setControllerVisibilityListener(new PlayerControlView.VisibilityListener() {
@Override
public void onVisibilityChange(int visibility) {
Log.e("Visibil", String.valueOf(visibility));
if (visibility==0){
imgBack.setVisibility(VISIBLE);
imgFull.setVisibility(VISIBLE);
imgfit.setVisibility(VISIBLE);
}else {
imgBack.setVisibility(GONE);
imgFull.setVisibility(GONE);
imgfit.setVisibility(GONE);
}
}
});
Uri uri = Uri.parse(url);
MediaSource mediaSource = null;
if (type.equals("hls")){
mediaSource = hlsMediaSource(uri,context);
}else if (type.equals("youtube")){
Log.e("youtube url :: ",url);
extractYoutubeUrl(url,context);
}
else if (type.equals("rtmp")){
mediaSource=rtmpMediaSource(uri);
}else {
mediaSource=mediaSource(uri);
}
player.prepare(mediaSource, true, false);
player.addListener(new Player.DefaultEventListener() {
@Override
public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
if (playWhenReady && playbackState == Player.STATE_READY) {
isPlaying=true;
progressBar.setVisibility(View.GONE);
Log.e("STATE PLAYER:::", String.valueOf(isPlaying));
}
else if (playbackState==Player.STATE_READY){
progressBar.setVisibility(View.GONE);
isPlaying=false;
Log.e("STATE PLAYER:::", String.valueOf(isPlaying));
}
else if (playbackState==Player.STATE_BUFFERING) {
isPlaying=false;
progressBar.setVisibility(VISIBLE);
Log.e("STATE PLAYER:::", String.valueOf(isPlaying));
} else {
// player paused in any state
isPlaying=false;
Log.e("STATE PLAYER:::", String.valueOf(isPlaying));
}
}
});
}
private void extractYoutubeUrl(String url,Context context) {
new YouTubeExtractor(context) {
@Override
public void onExtractionComplete(SparseArray<YtFile> ytFiles, VideoMeta vMeta) {
if (ytFiles != null) {
int itag = 18;
String downloadUrl = ytFiles.get(itag).getUrl();
Log.e("YOUTUBE::", String.valueOf(downloadUrl));
try {
MediaSource mediaSource = mediaSource(Uri.parse(downloadUrl));
player.prepare(mediaSource, true, false);
}catch (Exception e){
}
}
}
}.extract(url, true, true);
}
private MediaSource rtmpMediaSource(Uri uri){
MediaSource videoSource = null;
RtmpDataSourceFactory dataSourceFactory = new RtmpDataSourceFactory();
videoSource = new ExtractorMediaSource.Factory(dataSourceFactory)
.createMediaSource(uri);
return videoSource;
}
private MediaSource hlsMediaSource(Uri uri,Context context){
DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(context,
Util.getUserAgent(context, "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/JioTV/537.36 (KHTML, like Gecko) Chrome/63.0.3239.84 Safari/537.36"), bandwidthMeter);
MediaSource videoSource = new HlsMediaSource.Factory(dataSourceFactory)
.createMediaSource(uri);
return videoSource;
}
private MediaSource mediaSource(Uri uri){
return new ExtractorMediaSource.Factory(
new DefaultHttpDataSourceFactory("exoplayer")).
createMediaSource(uri);
}
private void addToFav(String url){
JsonObjectRequest jsonObjectRequest=new JsonObjectRequest(Request.Method.GET, url, null, new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
try {
if (response.getString("status").equals("success")){
new ToastMsg(DetailsActivity.this).toastIconSuccess(response.getString("message"));
isFav=true;
imgAddFav.setBackgroundResource(R.drawable.outline_favorite_24);
}else {
new ToastMsg(DetailsActivity.this).toastIconError(response.getString("message"));
}
}catch (Exception e){
}finally {
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
new ToastMsg(DetailsActivity.this).toastIconError(getString(R.string.error_toast));
}
});
new VolleySingleton(DetailsActivity.this).addToRequestQueue(jsonObjectRequest);
}
private void getTvData(String vtype,String vId){
String type = "&&type="+vtype;
String id = "&id="+vId;
String url = new ApiResources().getDetails()+type+id;
JsonObjectRequest jsonObjectRequest=new JsonObjectRequest(Request.Method.GET, url, null, new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
swipeRefreshLayout.setRefreshing(false);
shimmerFrameLayout.stopShimmer();
shimmerFrameLayout.setVisibility(GONE);
try {
tvName.setText(response.getString("tv_name"));
tvDes.setText(response.getString("description"));
V_URL=response.getString("stream_url");
CommonModels model=new CommonModels();
model.setTitle("HD");
model.setStremURL(V_URL);
model.setServerType(response.getString("stream_from"));
listDirector.add(model);
JSONArray jsonArray = response.getJSONArray("all_tv_channel");
for (int i=0;i<jsonArray.length();i++){
JSONObject jsonObject=jsonArray.getJSONObject(i);
CommonModels models =new CommonModels();
models.setImageUrl(jsonObject.getString("poster_url"));
models.setTitle(jsonObject.getString("tv_name"));
models.setVideoType("tv");
models.setId(jsonObject.getString("live_tv_id"));
listRelated.add(models);
}
relatedTvAdapter.notifyDataSetChanged();
JSONArray serverArray = response.getJSONArray("additional_media_source");
for (int i = 0;i<serverArray.length();i++){
JSONObject jsonObject=serverArray.getJSONObject(i);
CommonModels models=new CommonModels();
models.setTitle(jsonObject.getString("label"));
models.setStremURL(jsonObject.getString("url"));
models.setServerType(jsonObject.getString("source"));
listDirector.add(models);
}
serverApater.notifyDataSetChanged();
}catch (Exception e){
}finally {
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
swipeRefreshLayout.setRefreshing(false);
}
});
new VolleySingleton(DetailsActivity.this).addToRequestQueue(jsonObjectRequest);
}
private void getSeriesData(String vtype,String vId){
String type = "&&type="+vtype;
String id = "&id="+vId;
String url = new ApiResources().getDetails()+type+id;
JsonObjectRequest jsonObjectRequest=new JsonObjectRequest(Request.Method.GET, url, null, new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
swipeRefreshLayout.setRefreshing(false);
shimmerFrameLayout.stopShimmer();
shimmerFrameLayout.setVisibility(GONE);
try {
tvName.setText(response.getString("title"));
tvRelease.setText("Release On "+response.getString("release"));
tvDes.setText(response.getString("description"));
//----realted post---------------
JSONArray relatedArray = response.getJSONArray("related_tvseries");
for (int i = 0;i<relatedArray.length();i++){
JSONObject jsonObject=relatedArray.getJSONObject(i);
CommonModels models=new CommonModels();
models.setTitle(jsonObject.getString("title"));
models.setImageUrl(jsonObject.getString("thumbnail_url"));
models.setId(jsonObject.getString("videos_id"));
models.setVideoType("tvseries");
listRelated.add(models);
}
relatedAdapter.notifyDataSetChanged();
//----episode------------
JSONArray mainArray = response.getJSONArray("season");
for (int i = 0;i<mainArray.length();i++){
//epList.clear();
JSONObject jsonObject=mainArray.getJSONObject(i);
CommonModels models=new CommonModels();
String season_name=jsonObject.getString("seasons_name");
models.setTitle(jsonObject.getString("seasons_name"));
Log.e("Season Name 1::",jsonObject.getString("seasons_name"));
JSONArray episodeArray=jsonObject.getJSONArray("episodes");
List<EpiModel> epList=new ArrayList<>();
for (int j=0;j<episodeArray.length();j++){
JSONObject object =episodeArray.getJSONObject(j);
EpiModel model=new EpiModel();
model.setSeson(season_name);
model.setEpi(object.getString("episodes_name"));
model.setStreamURL(object.getString("file_url"));
model.setServerType(object.getString("file_type"));
epList.add(model);
}
models.setListEpi(epList);
listDirector.add(models);
episodeAdapter=new EpisodeAdapter(DetailsActivity.this,listDirector);
rvServer.setAdapter(episodeAdapter);
episodeAdapter.notifyDataSetChanged();
}
}catch (Exception e){
}finally {
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
swipeRefreshLayout.setRefreshing(false);
}
});
new VolleySingleton(DetailsActivity.this).addToRequestQueue(jsonObjectRequest);
}
private void getData(String vtype,String vId){
String type = "&&type="+vtype;
String id = "&id="+vId;
String url = new ApiResources().getDetails()+type+id;
JsonObjectRequest jsonObjectRequest=new JsonObjectRequest(Request.Method.GET, url, null, new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
shimmerFrameLayout.stopShimmer();
shimmerFrameLayout.setVisibility(GONE);
swipeRefreshLayout.setRefreshing(false);
try {
tvName.setText(response.getString("title"));
tvRelease.setText("Released On "+response.getString("release"));
tvDes.setText(response.getString("description"));
//----realted post---------------
JSONArray relatedArray = response.getJSONArray("related_movie");
for (int i = 0;i<relatedArray.length();i++){
JSONObject jsonObject=relatedArray.getJSONObject(i);
CommonModels models=new CommonModels();
models.setTitle(jsonObject.getString("title"));
models.setImageUrl(jsonObject.getString("thumbnail_url"));
models.setId(jsonObject.getString("videos_id"));
models.setVideoType("movie");
listRelated.add(models);
}
relatedAdapter.notifyDataSetChanged();
}catch (Exception e){
}finally {
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
swipeRefreshLayout.setRefreshing(false);
}
});
new VolleySingleton(DetailsActivity.this).addToRequestQueue(jsonObjectRequest);
}
}
最佳答案
试试这个
// i have edit your adapter class
public class ServerApater extends RecyclerView.Adapter<ServerApater.OriginalViewHolder> {
private List<CommonModels> items = new ArrayList<>();
private Context ctx;
private View.OnClickListener onClickListener;
public ServerApater(Context context, List<CommonModels> items,View.OnClickListener onClickListener) {
this.items = items;
ctx = context;
this.onClickListener=onClickListener;
}
@Override
public ServerApater.OriginalViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
ServerApater.OriginalViewHolder vh;
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.card_server, parent, false);
v.findViewById(R.id.card_view_home).setOnClickListener(onClickListener);
vh = new ServerApater.OriginalViewHolder(v);
return vh;
}
@Override
public void onBindViewHolder(final ServerApater.OriginalViewHolder holder, final int position) {
CommonModels obj = items.get(position);
holder.name.setText(obj.getTitle());
if (position==0){
viewHolder=holder;
new DetailsActivity().iniMoviePlayer(obj.getStremURL(),obj.getServerType(),ctx);
holder.name.setTextColor(ctx.getResources().getColor(R.color.colorPrimary));
}
holder.cardView.setTag(obj);
}
@Override
public int getItemCount() {
return items.size();
}
public class OriginalViewHolder extends RecyclerView.ViewHolder {
public TextView name;
public CardView cardView;
public OriginalViewHolder(View v) {
super(v);
name = v.findViewById(R.id.name);
cardView=v.findViewById(R.id.card_view_home);
}
}
public void chanColor(ServerApater.OriginalViewHolder holder,int pos){
if (pos!=0){
viewHolder.name.setTextColor(ctx.getResources().getColor(R.color.grey_60));
}
if (holder!=null){
holder.name.setTextColor(ctx.getResources().getColor(R.color.grey_60));
}
}
}
// call Adapter from activity like this
ServerApater serverApater=new ServerApater(this,"pass here commonModel type
list",this);
// implement View.OnClickListener with Activity like this
AppActivity extends AppCompatActivity implements View.OnClickListener
// then implement onclick() method
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.card_view_home:
CommonModels obj = (CommonModels) v.getTag();
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse(obj.getStremURL()), "video/*");
startActivity(Intent.createChooser(intent, "Complete action using"));
break;
}
}
关于java - 从适配器获取链接到 Activity ,然后在外部播放器中打开链接?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56297562/
我需要您在以下方面提供帮助。近一个月来,我一直在阅读有关任务和异步的内容。 我想尝试在一个简单的 wep api 项目中实现我新获得的知识。我有以下方法,并且它们都按预期工作: public Htt
我的可执行 jar 中有一个模板文件 (.xls)。不需要在运行时我需要为这个文件创建 100 多个副本(稍后将唯一地附加)。用于获取 jar 文件中的资源 (template.xls)。我正在使用
我在查看网站的模型代码时对原型(prototype)有疑问。我知道这对 Javascript 中的继承很有用。 在这个例子中... define([], function () { "use
影响我性能的前三项操作是: 获取滚动条 获取偏移高度 Ext.getStyle 为了解释我的应用程序中发生了什么:我有一个网格,其中有一列在每个单元格中呈现网格。当我几乎对网格的内容做任何事情时,它运
我正在使用以下函数来获取 URL 参数。 function gup(name, url) { name = name.replace(/[\[]/, '\\\[').replace(/[\]]/,
我最近一直在使用 sysctl 来做很多事情,现在我使用 HW_MACHINE_ARCH 变量。我正在使用以下代码。请注意,当我尝试获取其他变量 HW_MACHINE 时,此代码可以完美运行。我还认为
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 关闭 9 年前。 要求提供代码的问题必须表现出对所解决问题的最低限度的理解。包括尝试过的解决方案、为什么
由于使用 main-bower-files 作为使用 Gulp 的编译任务的一部分,我无法使用 node_modules 中的 webpack 来require 模块code> dir 因为我会弄乱当
关闭。这个问题需要更多focused .它目前不接受答案。 想改进这个问题吗? 更新问题,使其只关注一个问题 editing this post . 关闭 5 年前。 Improve this qu
我使用 Gridlayout 在一行中放置 4 个元素。首先,我有一个 JPanel,一切正常。对于行数变大并且我必须能够向下滚动的情况,我对其进行了一些更改。现在我的 JPanel 上添加了一个 J
由于以下原因,我想将 VolumeId 的值保存在变量中: #!/usr/bin/env python import boto3 import json import argparse import
我正在将 MSAL 版本 1.x 更新为 MSAL-browser 的 Angular 。所以我正在尝试从版本 1.x 迁移到 2.X.I 能够成功替换代码并且工作正常。但是我遇到了 acquireT
我知道有很多关于此的问题,例如 Getting daily averages with pandas和 How get monthly mean in pandas using groupby但我遇到
This is the query string that I am receiving in URL. Output url: /demo/analysis/test?startDate=Sat+
我正在尝试使用 javascript 中的以下代码访问 Geoserver 层 var gkvrtWmsSource =new ol.source.ImageWMS({ u
API 需要一个包含授权代码的 header 。这就是我到目前为止所拥有的: var fullUrl = 'https://api.ecobee.com/1/thermostat?json=\{"s
如何获取文件中的最后一个字符,如果是某个字符,则删除它而不将整个文件加载到内存中? 这就是我目前所拥有的。 using (var fileStream = new FileStream("file.t
我是这个社区的新手,想出了我的第一个问题。 我正在使用 JSP,我成功地创建了 JSP-Sites,它正在使用jsp:setParameter 和 jsp:getParameter 具有单个字符串。
在回答 StoreStore reordering happens when compiling C++ for x86 @Peter Cordes 写过 For Acquire/Release se
我有一个函数,我们将其命名为 X1,它返回变量 Y。该函数在操作 .on("focusout", X1) 中使用。如何获取变量Y?执行.on后X1的结果? 最佳答案 您可以更改 Y 的范围以使其位于函
我是一名优秀的程序员,十分优秀!