Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.ci.riadalsaliheenradio;
- import java.util.LinkedList;
- import java.util.concurrent.ExecutionException;
- import org.apache.http.HttpEntity;
- import org.apache.http.HttpResponse;
- import org.apache.http.client.HttpClient;
- import org.apache.http.client.methods.HttpGet;
- import org.apache.http.impl.client.DefaultHttpClient;
- import org.apache.http.params.BasicHttpParams;
- import org.apache.http.params.HttpConnectionParams;
- import org.apache.http.params.HttpParams;
- import org.apache.http.util.EntityUtils;
- import org.json.JSONArray;
- import org.json.JSONException;
- import org.json.JSONObject;
- import com.riadalsaliheenradio.R;
- import com.nostra13.universalimageloader.core.ImageLoader;
- import com.nostra13.universalimageloader.core.assist.FailReason;
- import com.nostra13.universalimageloader.core.listener.SimpleImageLoadingListener;
- import com.spoledge.aacdecoder.MultiPlayer;
- import com.spoledge.aacdecoder.PlayerCallback;
- import android.app.Activity;
- import android.app.Notification;
- import android.app.NotificationManager;
- import android.app.PendingIntent;
- import android.app.PendingIntent.CanceledException;
- import android.content.BroadcastReceiver;
- import android.content.ContentResolver;
- import android.content.Context;
- import android.content.Intent;
- import android.content.res.Resources;
- import android.graphics.Bitmap;
- import android.media.AudioTrack;
- import android.net.Uri;
- import android.os.AsyncTask;
- import android.os.Bundle;
- import android.os.Environment;
- import android.os.Handler;
- import android.support.v4.app.NotificationCompat;
- import android.support.v4.view.PagerAdapter;
- import android.support.v4.view.ViewPager;
- import android.support.v4.view.ViewPager.OnPageChangeListener;
- import android.view.LayoutInflater;
- import android.view.View;
- import android.view.View.OnClickListener;
- import android.view.ViewGroup;
- import android.widget.ImageView;
- import android.widget.LinearLayout;
- import android.widget.ProgressBar;
- import android.widget.RelativeLayout;
- import android.widget.RemoteViews;
- import android.widget.ScrollView;
- import android.widget.TextView;
- import android.widget.Toast;
- public class RadioMainActivity extends Activity implements OnClickListener, PlayerCallback {
- public static NotificationManager mNotificationManager;
- public static Notification notification;
- public static RemoteViews contentView;
- ViewPager viewpager;
- MyPager adpt;
- ImageView imgStationList, iv_exit;
- ScrollView rel_right_pannel;
- static ImageView imgPlayPause;
- ImageView img_right_menu;
- ImageView record_btn, sharebtn;
- String share_text = "Share this text";
- static MultiPlayer multiPlayer;
- static boolean isMusicPlaying = false;
- static String PLAY = "play";
- static String STOP = "stop";
- ProgressBar progressLoading;
- LinearLayout ll_pannel;
- RelativeLayout rel_root;
- Handler uiHandler = new Handler();
- // TextView txtStationName, text_songtitle, text_song_artist,
- // txtListercount;
- //static boolean is_playing = false;
- Boolean recordFlag = true;
- boolean is_reset = false;
- ImageLoader imageLoader = ImageLoader.getInstance();
- private String filepath = Environment.getExternalStorageDirectory().getAbsolutePath() + "/Radio/RecordList/";
- static String current_btn = PLAY;
- String value;
- boolean flag = false;
- static Intent notification_intent = null;
- LinearLayout view_pager_indicator;
- String url = "";
- // static MyNotification notification;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.radio_activity_main);
- imageLoader.init(GetOption.getConfig(RadioMainActivity.this));
- imgStationList = (ImageView) findViewById(R.id.imgStationList);
- img_right_menu = (ImageView) findViewById(R.id.img_right_menu);
- iv_exit = (ImageView) findViewById(R.id.iv_exit);
- ll_pannel = (LinearLayout) findViewById(R.id.ll_pannel);
- viewpager = (ViewPager) findViewById(R.id.viewpager);
- view_pager_indicator = (LinearLayout) findViewById(R.id.view_pager_indicator);
- viewpager.setOffscreenPageLimit(3);
- viewpager.setOnPageChangeListener(new OnPageChangeListener() {
- @Override
- public void onPageSelected(int position) {
- RadioListActivity.stationPosition = position;
- stop();
- ViewPagerIndicator.createDotScrollBar(RadioMainActivity.this, view_pager_indicator,
- viewpager.getCurrentItem(), adpt.getCount());
- }
- @Override
- public void onPageScrolled(int arg0, float arg1, int arg2) {
- }
- @Override
- public void onPageScrollStateChanged(int arg0) {
- }
- });
- rel_right_pannel = (ScrollView) findViewById(R.id.rel_right_pannel);
- rel_root = (RelativeLayout) findViewById(R.id.rel_root);
- new MyNotification(this);
- imgPlayPause = (ImageView) findViewById(R.id.imgPlayPause);
- progressLoading = (ProgressBar) findViewById(R.id.progressLoading);
- record_btn = (ImageView) findViewById(R.id.recordBtn);
- sharebtn = (ImageView) findViewById(R.id.sharebtn);
- imgPlayPause.setVisibility(View.VISIBLE);
- progressLoading.setVisibility(View.GONE);
- if (isMusicPlaying) {
- setTooglePlayPause(PLAY, imgPlayPause);
- } else {
- setTooglePlayPause(STOP, imgPlayPause);
- }
- imgStationList.setOnClickListener(this);
- imgPlayPause.setOnClickListener(this);
- record_btn.setOnClickListener(this);
- sharebtn.setOnClickListener(this);
- img_right_menu.setOnClickListener(this);
- iv_exit.setOnClickListener(this);
- setLoadView(Constant.CallGetStation);
- if (RadioListActivity.stationList == null || RadioListActivity.stationList.size() <= 0) {
- WebAPIHelper helper = new WebAPIHelper(Constant.CallGetStation, RadioMainActivity.this, true);
- helper.callRequest(Constant.streaming + "?device=1&device_id=" + Constant.device_id);
- } else {
- WebAPIHelper helper = new WebAPIHelper(Constant.CallGetStation, RadioMainActivity.this, false);
- helper.callRequest(Constant.streaming + "?device=1&device_id=" + Constant.device_id);
- }
- new GetImageList().execute();
- }
- @Override
- protected void onDestroy() {
- mNotificationManager.cancel(548853);
- super.onDestroy();
- }
- public void setTooglePlayPause(String btn, ImageView img) {
- img.setImageBitmap(null);
- current_btn = btn;
- if (btn.equals(PLAY)) {
- img.setImageResource(R.drawable.stop);
- } else {
- img.setImageResource(R.drawable.play);
- }
- setNotificationContent(RadioMainActivity.this);
- }
- @Override
- public void onClick(View v) {
- switch (v.getId()) {
- case R.id.imgStationList:
- Intent inStationList = new Intent(RadioMainActivity.this, RadioListActivity.class);
- startActivity(inStationList);
- overridePendingTransition(R.anim.back_slide_in, R.anim.back_slide_out);
- break;
- case R.id.imgPlayPause:
- if (isMusicPlaying) {
- stop();
- } else {
- start();
- }
- break;
- case R.id.iv_exit:
- stop();
- finish();
- break;
- case R.id.sharebtn:
- Intent intent = null;
- Resources resources = getResources();
- Uri uri = Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE + "://"
- + resources.getResourcePackageName(R.drawable.share_image) + '/'
- + resources.getResourceTypeName(R.drawable.share_image) + '/'
- + resources.getResourceEntryName(R.drawable.share_image));
- intent = new Intent(Intent.ACTION_SEND);
- intent.putExtra(Intent.EXTRA_STREAM, uri);
- intent.setType("image/*");
- intent.putExtra(Intent.EXTRA_SUBJECT, "تطبيق إذاعة مركز رياض الصالحين");
- intent.putExtra(Intent.EXTRA_TEXT, "http://bit.ly/riadalsaliheenapk \nhttp://bit.ly/riadalsaliheenios");
- startActivity(Intent.createChooser(intent, "شارك التطبيق"));
- break;
- // case R.id.iv_share_icon:
- // Intent sharingIntent = new Intent(
- // android.content.Intent.ACTION_SEND);
- // sharingIntent.setType("text/plain");
- // sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,
- // "Radio");
- // sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT,
- // share_text);
- // startActivity(Intent.createChooser(sharingIntent,
- // "حصة هذا باستخدام"));
- // break;
- case R.id.img_right_menu:
- if (rel_right_pannel.getVisibility() == View.VISIBLE) {
- rel_right_pannel.setVisibility(View.GONE);
- RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
- RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);
- params.setMargins(0, 0, 0, 0);
- params.addRule(RelativeLayout.LEFT_OF, R.id.rel_right_pannel);
- rel_root.setLayoutParams(params);
- } else {
- rel_right_pannel.setVisibility(View.VISIBLE);
- RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
- RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);
- params.setMargins(-(getResources().getDimensionPixelSize(R.dimen.six_zero)), 0, 0, 0);
- params.addRule(RelativeLayout.LEFT_OF, R.id.rel_right_pannel);
- rel_root.setLayoutParams(params);
- }
- break;
- }
- }
- private void start() {
- try {
- if (multiPlayer != null && isMusicPlaying) {
- imgPlayPause.setVisibility(View.VISIBLE);
- progressLoading.setVisibility(View.GONE);
- } else {
- stop();
- multiPlayer = new MultiPlayer(this);
- imgPlayPause.setVisibility(View.GONE);
- progressLoading.setVisibility(View.VISIBLE);
- multiPlayer.setAudioBufferCapacityMs(3000);
- multiPlayer.playAsync(getUrl());
- // multiPlayer.setOnPreparedListener(new OnPreparedListener() {
- // @Override
- // public void onPrepared(MediaPlayer mp) {
- // if (multiPlayer != null) {
- // setTooglePlayPause(PLAY, imgPlayPause);
- // imgPlayPause.setVisibility(View.VISIBLE);
- // progressLoading.setVisibility(View.GONE);
- // multiPlayer.start();
- // isMusicPlaying = true;
- // }
- // }
- // });
- // multiPlayer.setOnErrorListener(new OnErrorListener() {
- // @Override
- // public boolean onError(MediaPlayer mp, int what, int extra) {
- // if (what != -38) {
- // progressLoading.setVisibility(View.GONE);
- // imgPlayPause.setVisibility(View.VISIBLE);
- // new AlertDialog.Builder(RadioMainActivity.this)
- // .setTitle("لم يتم تشغيل الإذاعة")
- // .setMessage("البث متوقف أو مشكلة في الإتصال. المرجو إعادة
- // المحاولة")
- // .setNeutralButton(
- // "إغلاق",
- // new DialogInterface.OnClickListener() {
- // public void onClick(
- // DialogInterface dialog,
- // int id) {
- // dialog.cancel();
- // }
- // }).show();
- // }
- // return false;
- // }
- // });
- }
- } catch (Exception e) {
- }
- }
- private void stop() {
- if (multiPlayer != null) {
- isMusicPlaying = false;
- multiPlayer.stop();
- multiPlayer = null;
- }
- }
- private String getUrl() {
- if (RadioListActivity.stationList == null || RadioListActivity.stationList.size() <= 0) {
- return "";
- }
- if (RadioListActivity.stationList.get(RadioListActivity.stationPosition).pls_url.equals("")) {
- LinkedList<String> urls = null;
- GetStreamingUrl oGetStreamingUrl = new GetStreamingUrl(RadioMainActivity.this,
- RadioListActivity.stationList.get(RadioListActivity.stationPosition).getStreaming_url());
- try {
- urls = oGetStreamingUrl.execute().get();
- } catch (InterruptedException e) {
- e.printStackTrace();
- } catch (ExecutionException e) {
- e.printStackTrace();
- }
- if (urls != null && urls.size() > 0) {
- Station staion = RadioListActivity.stationList.get(RadioListActivity.stationPosition);
- staion.pls_url = urls.get(0);
- RadioListActivity.stationList.set(RadioListActivity.stationPosition, staion);
- return urls.get(0);
- } else
- return "";
- } else {
- return RadioListActivity.stationList.get(RadioListActivity.stationPosition).pls_url;
- }
- }
- private String getImage(int position) {
- if (RadioListActivity.stationList == null || RadioListActivity.stationList.size() <= 0) {
- return "";
- }
- String ret = RadioListActivity.stationList.get(position).getLogo();
- return ret;
- }
- @Override
- protected void onResume() {
- super.onResume();
- if (RadioListActivity.stationList != null && RadioListActivity.stationList.size() > 0) {
- if (viewpager != null && adpt != null && adpt.getCount() > RadioListActivity.stationPosition) {
- viewpager.setCurrentItem(RadioListActivity.stationPosition, true);
- // start();
- } else {
- start();
- }
- }
- }
- public class GetImageList extends AsyncTask<Void, Void, Void> {
- String jsonResponse;
- // String stationUrl = "http://sunnapod.com/service/icon.php";
- public GetImageList() {
- }
- @Override
- protected Void doInBackground(Void... params) {
- try {
- HttpParams httpParameters = new BasicHttpParams();
- HttpConnectionParams.setConnectionTimeout(httpParameters, 10000);
- HttpConnectionParams.setSoTimeout(httpParameters, 10000);
- HttpClient client = new DefaultHttpClient(httpParameters);
- HttpResponse response = client.execute(new HttpGet(Constant.icon_Url));
- HttpEntity resEntity = response.getEntity();
- jsonResponse = EntityUtils.toString(resEntity);
- } catch (Exception e) {
- }
- return null;
- }
- @Override
- protected void onPostExecute(Void result) {
- super.onPostExecute(result);
- try {
- JSONArray jArray = new JSONArray(jsonResponse);
- for (int i = 0; i < jArray.length(); i++) {
- JSONObject jobj = jArray.getJSONObject(i);
- if (jobj.getString("status").equals("Active")) {
- if (jobj.getString("type").equals("web")) {
- final String url_call = jobj.getString("url");
- record_btn.setVisibility(View.VISIBLE);
- if (GetOption.check(jobj.optString("logo"))) {
- imageLoader.displayImage(jobj.optString("logo"), record_btn, GetOption.getOption());
- }
- record_btn.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- if (url_call != null && !url_call.equals("")) {
- Intent intent_youtube = new Intent(RadioMainActivity.this, OpenSharing.class);
- intent_youtube.putExtra("url", url_call);
- startActivity(intent_youtube);
- overridePendingTransition(R.anim.slide_in, R.anim.slide_out);
- }
- }
- });
- } else {
- ll_pannel.addView(getView(jobj), ll_pannel.getChildCount() - 2);
- }
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
- private View getView(JSONObject jobj) {
- View child = getLayoutInflater().inflate(R.layout.row_layout, null);
- ImageView iv_icon = (ImageView) child.findViewById(R.id.iv_icon);
- if (GetOption.check(jobj.optString("logo"))) {
- imageLoader.displayImage(jobj.optString("logo"), iv_icon, GetOption.getOption());
- }
- try {
- final String mode = jobj.getString("type");
- final String url_call = jobj.getString("url");
- iv_icon.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- if (mode.equals("mail")) {
- try {
- Intent emailIntent = new Intent(Intent.ACTION_SENDTO,
- emailIntent.putExtra(Intent.EXTRA_SUBJECT, "تطبيق إذاعة مركز رياض الصالحين");
- startActivity(Intent.createChooser(emailIntent, "إرسال بريد عن طريق ..."));
- } catch (Exception e) {
- Toast.makeText(getApplicationContext(), "لايوجد تطبيق بريدي", Toast.LENGTH_LONG).show();
- }
- } else {
- Intent intent_youtube = new Intent(RadioMainActivity.this, OpenSharing.class);
- intent_youtube.putExtra("url", url_call);
- startActivity(intent_youtube);
- overridePendingTransition(R.anim.slide_in, R.anim.slide_out);
- }
- }
- });
- } catch (JSONException e) {
- e.printStackTrace();
- }
- return child;
- }
- public class MyNotification extends Notification {
- private Context ctx;
- public MyNotification(Context ctx) {
- super();
- this.ctx = ctx;
- String ns = Context.NOTIFICATION_SERVICE;
- mNotificationManager = (NotificationManager) ctx.getSystemService(ns);
- // app name bar status
- CharSequence tickerText = "إذاعة مركز رياض الصالحين";
- // CharSequence tickerText="@string/app_name";
- long when = System.currentTimeMillis();
- notification = new NotificationCompat.Builder(ctx).build();
- notification.when = when;
- notification.tickerText = tickerText;
- notification.icon = R.drawable.ic_launcher;
- setNotificationContent(ctx);
- }
- }
- public static void setNotificationContent(Context ctx) {
- // TODO Auto-generated method stub
- if (notification_intent == null) {
- contentView = new RemoteViews(ctx.getPackageName(), R.layout.notification_layout);
- Intent notificationIntent = new Intent(ctx, RadioMainActivity.class);
- PendingIntent pendingNotificationIntent = PendingIntent.getActivity(ctx, 0, notificationIntent, 0);
- // for play pause
- Intent notification_intent = new Intent(ctx, switchButtonListener.class);
- notification_intent.setAction("com.application.RADIO_UPDATE");
- PendingIntent penPlay = PendingIntent.getBroadcast(ctx, 0, notification_intent,
- PendingIntent.FLAG_UPDATE_CURRENT);
- Intent notification_intent_click = new Intent(ctx, switchButtonListener.class);
- notification_intent_click.setAction("com.application.RADIO_UPDATE_CLICK");
- PendingIntent penPlay_click = PendingIntent.getBroadcast(ctx, 0, notification_intent_click,
- PendingIntent.FLAG_UPDATE_CURRENT);
- contentView.setOnClickPendingIntent(R.id.radio_notification_play_pause, penPlay_click);
- try {
- penPlay.send();
- } catch (CanceledException e) {
- e.printStackTrace();
- }
- notification.contentIntent = pendingNotificationIntent;
- notification.contentView = contentView;
- mNotificationManager.notify(548853, notification);
- } else {
- PendingIntent penPlay = PendingIntent.getBroadcast(ctx, 0, notification_intent,
- PendingIntent.FLAG_UPDATE_CURRENT);
- try {
- penPlay.send();
- } catch (CanceledException e) {
- e.printStackTrace();
- }
- }
- }
- public static class switchButtonListener extends BroadcastReceiver {
- @Override
- public void onReceive(Context context, Intent intent) {
- if (intent.getAction().equals("com.application.RADIO_UPDATE") && contentView != null) {
- if (current_btn.equals(PLAY)) {
- contentView.setImageViewResource(R.id.radio_notification_play_pause, R.drawable.stop);
- } else {
- contentView.setImageViewResource(R.id.radio_notification_play_pause, R.drawable.play);
- }
- if (RadioListActivity.stationList != null
- && RadioListActivity.stationList.size() > RadioListActivity.stationPosition) {
- contentView.setTextViewText(R.id.text_notification_radio_station,
- RadioListActivity.stationList.get(RadioListActivity.stationPosition).getTrack_title());
- contentView.setTextViewText(R.id.text_notification_radio_songtitle,
- RadioListActivity.stationList.get(RadioListActivity.stationPosition).getArtist_name());
- notification.contentView = contentView;
- mNotificationManager.notify(548853, notification);
- }
- } else if (intent.getAction().equals("com.application.RADIO_UPDATE_CLICK")) {
- if (imgPlayPause != null) {
- imgPlayPause.performClick();
- } else {
- mNotificationManager.cancel(548853);
- }
- }
- }
- }
- public void setLoadView(int requestNumber) {
- try {
- RadioListActivity.stationList.clear();
- JSONArray jArray = new JSONArray(
- SecurePreferences.getPreference(String.valueOf(requestNumber), "", RadioMainActivity.this));
- for (int i = 0; i < jArray.length(); i++) {
- Station station = new Station();
- JSONObject jobj = jArray.getJSONObject(i);
- station.id = jobj.optString("url");
- station.name = jobj.optString("name");
- station.streaming_url = jobj.optString("streaming_url");
- station.json_url = jobj.optString("json_url");
- WebAPIHelper helper = new WebAPIHelper(Constant.call_json_url, RadioMainActivity.this, false, i);
- helper.callRequest(station.json_url);
- station.description = jobj.optString("description");
- station.logo = jobj.optString("logo");
- RadioListActivity.stationList.add(station);
- }
- final Handler handler = new Handler();
- handler.postDelayed(new Runnable() {
- @Override
- public void run() {
- if (RadioListActivity.stationList.size() > 0
- && RadioListActivity.stationList.size() > RadioListActivity.stationPosition) {
- WebAPIHelper helper = new WebAPIHelper(Constant.call_json_url, RadioMainActivity.this, false,
- RadioListActivity.stationPosition);
- helper.callRequest(
- RadioListActivity.stationList.get(RadioListActivity.stationPosition).json_url);
- System.out.println("service call"
- + RadioListActivity.stationList.get(RadioListActivity.stationPosition).json_url);
- }
- handler.postDelayed(this, 60000);
- }
- }, 60000);
- adpt = new MyPager();
- viewpager.setAdapter(adpt);
- ViewPagerIndicator.createDotScrollBar(RadioMainActivity.this, view_pager_indicator, 0,
- this.adpt.getCount());
- } catch (Exception e) {
- System.out.println(e.getMessage());
- }
- }
- public void setResponse(String response, int postion) {
- try {
- JSONObject j_obj = new JSONObject(response).getJSONArray("data").getJSONObject(0);
- Station staion = RadioListActivity.stationList.get(postion);
- staion.song_title = j_obj.optString("song");
- staion.artist_name = j_obj.getJSONObject("track").optString("artist");
- staion.track_title = j_obj.getJSONObject("track").optString("title");
- staion.listner = j_obj.optString("listeners");
- RadioListActivity.stationList.set(postion, staion);
- if (viewpager.getCurrentItem() == RadioListActivity.stationPosition) {
- if (adpt != null)
- adpt.notifyDataSetChanged();
- // txtStationName.setText(RadioListActivity.stationList.get(
- // RadioListActivity.stationPosition).getName());
- // text_songtitle.setText(RadioListActivity.stationList.get(
- // RadioListActivity.stationPosition).getTrack_title());
- // text_song_artist.setText(RadioListActivity.stationList.get(
- // RadioListActivity.stationPosition).getArtist_name());
- // txtListercount.setText(RadioListActivity.stationList.get(
- // RadioListActivity.stationPosition).getListner()
- // + " المستمع");
- }
- } catch (JSONException e) {
- e.printStackTrace();
- }
- }
- public class MyPager extends PagerAdapter {
- @Override
- public int getCount() {
- if (RadioListActivity.stationList == null || RadioListActivity.stationList.size() <= 0) {
- return 0;
- } else {
- return RadioListActivity.stationList.size();
- }
- }
- @Override
- public boolean isViewFromObject(View arg0, Object arg1) {
- return arg0 == arg1;
- }
- @Override
- public Object instantiateItem(ViewGroup container, final int position) {
- LayoutInflater inflate = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- View pager_layout = inflate.inflate(R.layout.viewpager_row, null);
- TextView txtStationName = (TextView) pager_layout.findViewById(R.id.txtStationName);
- TextView text_songtitle = (TextView) pager_layout.findViewById(R.id.text_songtitle);
- TextView text_song_artist = (TextView) pager_layout.findViewById(R.id.text_song_artist);
- TextView txtListercount = (TextView) pager_layout.findViewById(R.id.txtListercount);
- final ImageView radio_icon = (ImageView) pager_layout.findViewById(R.id.radio_icon);
- txtStationName.setText(RadioListActivity.stationList.get(position).getName());
- if (GetOption.check(getImage(position))) {
- imageLoader.displayImage(getImage(position), radio_icon, GetOption.getOption(),
- new SimpleImageLoadingListener() {
- @Override
- public void onLoadingStarted(String imageUri, View view) {
- radio_icon.setImageBitmap(null);
- }
- @Override
- public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
- }
- @Override
- public void onLoadingComplete(String imageUri, View view, final Bitmap loadedImage) {
- }
- });
- }
- txtStationName.setText(RadioListActivity.stationList.get(position).getName());
- text_songtitle.setText(RadioListActivity.stationList.get(position).getTrack_title());
- text_song_artist.setText(RadioListActivity.stationList.get(position).getArtist_name());
- txtListercount.setText("المستمعين: " + RadioListActivity.stationList.get(position).getListner());
- container.addView(pager_layout);
- return pager_layout;
- }
- public int getItemPosition(Object object) {
- return POSITION_NONE;
- }
- @Override
- public void destroyItem(ViewGroup container, int position, Object object) {
- container.removeView((RelativeLayout) object);
- }
- }
- @Override
- public void playerAudioTrackCreated(AudioTrack arg0) {
- // TODO Auto-generated method stub
- }
- @Override
- public void playerException(Throwable arg0) {
- start();
- // progressLoading.setVisibility(View.GONE);
- // imgPlayPause.setVisibility(View.VISIBLE);
- // new AlertDialog.Builder(RadioMainActivity.this)
- // .setTitle("لم يتم تشغيل الإذاعة")
- // .setMessage(
- // "البث متوقف أو مشكلة في الإتصال. المرجو إعادة المحاولة")
- // .setNeutralButton("إغلاق",
- // new DialogInterface.OnClickListener() {
- // public void onClick(DialogInterface dialog, int id) {
- // dialog.cancel();
- // }
- // }).show();
- }
- @Override
- public void playerMetadata(String arg0, String arg1) {
- }
- // @Override
- // public void playerPCMFeedBuffer(boolean arg0, int arg1, int arg2) {
- // System.out.println("Buffer");
- //
- // }
- @Override
- public void playerStarted() {
- uiHandler.post(new Runnable() {
- public void run() {
- setTooglePlayPause(PLAY, imgPlayPause);
- imgPlayPause.setVisibility(View.VISIBLE);
- progressLoading.setVisibility(View.GONE);
- isMusicPlaying = true;
- // is_playing = true;
- }
- });
- }
- @Override
- public void playerPCMFeedBuffer(final boolean isPlaying, final int audioBufferSizeMs,
- final int audioBufferCapacityMs) {
- // if (is_playing) {
- uiHandler.post(new Runnable() {
- public void run() {
- isMusicPlaying = isPlaying;
- progressLoading.setVisibility(View.GONE);
- imgPlayPause.setVisibility(View.VISIBLE);
- if (isMusicPlaying) {
- setTooglePlayPause(PLAY, imgPlayPause);
- }
- else
- {
- progressLoading.setVisibility(View.VISIBLE);
- imgPlayPause.setVisibility(View.GONE);
- }
- }
- });
- // }
- }
- @Override
- public void playerStopped(final int perf) {
- uiHandler.post(new Runnable() {
- public void run() {
- isMusicPlaying = false;
- // is_playing = false;
- setTooglePlayPause(STOP, imgPlayPause);
- }
- });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment