Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.watchsportbd.fblive.fragment;
- import havvn.libs.view.AdIDListener;
- import havvn.libs.view.AdIDManager;
- import io.vov.vitamio.LibsChecker;
- import java.util.ArrayList;
- import java.util.LinkedHashMap;
- import java.util.Locale;
- import java.util.Map;
- import org.json.JSONException;
- import org.json.JSONObject;
- import com.google.android.gms.ads.AdRequest;
- import com.google.android.gms.ads.AdSize;
- import com.google.android.gms.ads.InterstitialAd;
- //import com.google.ads.AdSize;
- import com.google.gson.Gson;
- //import com.inmobi.androidsdk.BannerView;
- import com.loopj.android.http.AsyncHttpClient;
- import com.loopj.android.http.AsyncHttpResponseHandler;
- import com.watchsportbd.fblive.CustomPlayVideo;
- import com.watchsportbd.fblive.DetailLiveScore;
- import com.watchsportbd.fblive.R;
- import com.watchsportbd.fblive.adapter.ExpandableListLiveScoreAdapter;
- import com.watchsportbd.fblive.adapter.ExpandableListTheThaoAdapter;
- import com.watchsportbd.fblive.adapter.adapter1ListTheThao;
- import com.watchsportbd.fblive.adapter.adapter1ListTrangChu;
- import com.watchsportbd.fblive.adapter.adapter1LiveScore;
- import com.watchsportbd.fblive.adapter.adapterTrangChu;
- import com.watchsportbd.fblive.database.MyDatabase;
- import com.watchsportbd.fblive.database.objTivi;
- import com.watchsportbd.fblive.obj.obj1CateNo;
- import com.watchsportbd.fblive.obj.obj1ListChannel;
- import com.watchsportbd.fblive.obj.obj1ListLiveScore;
- import com.watchsportbd.fblive.obj.obj1ListTheThao;
- import com.watchsportbd.fblive.obj.obj1Thethao;
- import com.watchsportbd.fblive.obj.obj1TiviK;
- import com.watchsportbd.fblive.obj.obj1TranDau;
- import com.watchsportbd.fblive.obj.objInfo;
- import com.watchsportbd.fblive.util.AdsDialog;
- import com.watchsportbd.fblive.util.MyConstans;
- import com.watchsportbd.fblive.util.MyDataPref;
- import com.watchsportbd.fblive.util.MyLog;
- import com.watchsportbd.fblive.util.MyUtil;
- //import com.searchboxsdk.android.StartAppSearch;
- //import com.startapp.android.publish.StartAppAd;
- //import com.tivifootballkplus.filmhd.util.AdflexHelper;
- import android.app.Activity;
- import android.app.AlertDialog;
- import android.content.DialogInterface;
- import android.content.Intent;
- import android.content.SharedPreferences;
- import android.content.pm.PackageManager.NameNotFoundException;
- import android.graphics.Bitmap;
- import android.net.Uri;
- import android.os.Bundle;
- import android.os.Handler;
- import android.support.v4.app.Fragment;
- import android.util.Log;
- import android.view.LayoutInflater;
- import android.view.View;
- import android.view.ViewGroup;
- import android.view.animation.AccelerateInterpolator;
- import android.view.animation.Animation;
- import android.view.animation.TranslateAnimation;
- import android.webkit.WebChromeClient;
- import android.webkit.WebView;
- import android.webkit.WebViewClient;
- import android.widget.AdapterView;
- import android.widget.ExpandableListAdapter;
- import android.widget.ExpandableListView;
- import android.widget.ExpandableListView.OnChildClickListener;
- import android.widget.GridView;
- import android.widget.ImageView;
- import android.widget.LinearLayout;
- import android.widget.ListView;
- import android.widget.ProgressBar;
- import android.widget.TextView;
- import android.widget.Toast;
- import android.widget.ViewFlipper;
- import android.widget.AdapterView.OnItemClickListener;
- import android.widget.TableRow.LayoutParams;
- import com.startapp.android.publish.StartAppAd;
- public class MainFragment extends Fragment {
- public TextView tvTitle;
- private ViewFlipper viewFliper;
- // private Context aContext;
- // private int maxValueWidth;
- public SharedPreferences prefs;
- public SharedPreferences.Editor editor;
- // private boolean mBack = false;
- private MyUtil myUtil;
- private MyDataPref myData1;
- // private String admodkey = "a1525ab0b0afef0";// "a15237fed2d5ac8";//
- // "a14fcf1cbf28ea8";
- // private String inmobiKey = "fdc0e73341344009977eeb4f65ea8b32";
- private LinearLayout adview;
- private View view;
- private MyDatabase myData;
- private ListView lvTrangChu;
- private ArrayList<obj1ListChannel> arrTrangChu;
- private ProgressBar mLoadWebview;
- private boolean isLoaded = false;
- // list phim
- private GridView gridTivi;
- private TextView tvTitleTivi;
- // the thao
- private ExpandableListView expListViewTheThao;
- private boolean isLoadedTheThao = false;
- private ArrayList<obj1ListTheThao> groupList;
- // private ArrayList<obj1Thethao> childList;/
- private Map<obj1ListTheThao, ArrayList<obj1Thethao>> thethaoCollection;
- // private ExpandableListView expListView;
- //livescore
- private boolean isLoadedScore = false;
- private ArrayList<obj1ListLiveScore> arrLiveScore;
- private ExpandableListView lvLiveScore;
- private Map<obj1ListLiveScore, ArrayList<obj1TranDau>> liveScoreCollection;
- // all of tivi for search or the thao
- private ArrayList<obj1TiviK> listAllTiviK;
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
- // TODO Auto-generated method stub
- view = inflater.inflate(R.layout.mainslide, container, false);
- ImageView imgback = (ImageView) view.findViewById(R.id.imgMainback);
- imgback.setOnClickListener(homeClickListenner);
- tvTitle = (TextView) view.findViewById(R.id.tvMainTitle);
- viewFliper = (ViewFlipper) view.findViewById(R.id.vfMainFliper1);
- mLoadWebview = (ProgressBar) view.findViewById(R.id.llLoadingWebview);
- // db = new MyDatabase(getActivity());
- myUtil = new MyUtil(getActivity());
- myData = new MyDatabase(getActivity());
- myData1 = new MyDataPref(getActivity());
- initViewFragment(view);
- iniStartApp();
- initAdmob();
- initInterstitialAds();
- showTab(MyConstans.FRAG_TRANGCHU, null);
- new Handler().postDelayed(new Runnable() {
- @Override
- public void run() {
- updateVersion();
- }
- }, 1000);
- return view;
- }
- private void initAdmob(){
- AdIDManager.getInstance();
- AdIDManager.initAdManager(getActivity(), AdSize.SMART_BANNER, MyConstans.ADDMOD_BANNER_ID);
- adview = (LinearLayout) view.findViewById(R.id.ad);
- LinearLayout.LayoutParams adWhirlLayoutParams = new LinearLayout.LayoutParams(
- LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
- adview.addView(AdIDManager.adviewLayout, adWhirlLayoutParams);
- AdIDManager.setAdview(adview);
- }
- private void initViewFragment(View view) {
- lvTrangChu = (ListView) view.findViewById(R.id.listTrangChu);
- arrTrangChu = new ArrayList<obj1ListChannel>();
- gridTivi = (GridView) view.findViewById(R.id.gridTivi);
- expListViewTheThao = (ExpandableListView) view.findViewById(R.id.listTheThao);
- lvLiveScore = (ExpandableListView ) view.findViewById(R.id.listLiveScore);
- // arrLiveScore = new ArrayList<obj1TranDau>();
- listAllTiviK = new ArrayList<obj1TiviK>();
- }
- @Override
- public void onActivityCreated(Bundle savedInstanceState) {
- // TODO Auto-generated method stub
- super.onActivityCreated(savedInstanceState);
- // selectTab(MyConstans.SLIDE_NEW);
- }
- private View.OnClickListener homeClickListenner = new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- // TODO Auto-generated method stub
- listenner.onMainClick();
- }
- };
- @Override
- public void onAttach(Activity activity) {
- super.onAttach(activity);
- // This makes sure that the container activity has implemented
- // the callback interface. If not, it throws an exception.
- try {
- listenner = (OnMainClickListenner) activity;
- } catch (ClassCastException e) {
- throw new ClassCastException(activity.toString()
- + " must implement OnMainClickListenner");
- }
- }
- OnMainClickListenner listenner;
- public interface OnMainClickListenner {
- public void onMainClick();
- }
- // ////////////////////////////
- public void showTab(int tag, obj1CateNo obj) {
- switch (tag) {
- case MyConstans.FRAG_TRANGCHU:
- tvTitle.setText(getResources().getString(R.string.home));
- showTrangChu(obj);
- break;
- case MyConstans.FRAG_NEWS:
- tvTitle.setText(obj.name.toUpperCase());
- showNEWS(obj);
- break;
- case MyConstans.FRAG_WEBVIEW:
- tvTitle.setText(obj.name.toUpperCase());
- showWEBVIEW(obj);
- break;
- case MyConstans.FRAG_LISTTIVI:
- tvTitle.setText(obj.name.toUpperCase());
- showListTivi(obj);
- break;
- case MyConstans.FRAG_SCORE:
- tvTitle.setText(obj.name.toUpperCase());
- showLiveScore(obj);
- break;
- default:
- break;
- }
- }
- public void setTitle(String text){
- tvTitle.setText(text.toUpperCase());
- }
- private void showTrangChu(obj1CateNo obj1) {
- slide(MyConstans.FRAG_TRANGCHU, true);
- try {
- showAdmob(false);
- if (obj1 != null && arrTrangChu != null) {
- MyLog.E("Co du lieu trang chu");
- ArrayList<obj1ListChannel> listACate = new ArrayList<obj1ListChannel>();
- for (obj1ListChannel _obj : arrTrangChu) {
- if (_obj.categoryId.contentEquals(obj1.id)) {
- listACate.add(_obj);
- }
- }
- try {
- adapterTrangChu adapter = new adapterTrangChu(
- MainFragment.this, R.layout.item_trangchu,
- listACate);
- lvTrangChu.setAdapter(adapter);
- // MyLog.E(">>>>size trang chu"+ arrTrangChu.size());
- } catch (Exception e) {
- // TODO: handle exception
- e.printStackTrace();
- // MyLog.E(">>>>EEEEERRRRR");
- }
- } else {
- MyLog.E("Khong Co du lieu trang chu");
- if (isLoaded)
- loadAllTrangChu();// cache
- else
- getAllTrangChu();
- }
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- private void showListTivi(obj1CateNo obj1) {
- slide(MyConstans.FRAG_LISTTIVI, true);
- try {
- showAdmob(false);
- if (obj1 != null && arrTrangChu != null) {
- ArrayList<obj1ListChannel> listACate = new ArrayList<obj1ListChannel>();
- for (obj1ListChannel _obj : arrTrangChu) {
- if (_obj.categoryId.contentEquals(obj1.id)) {
- listACate.add(_obj);
- }
- }
- try {
- adapter1ListTrangChu adapter = new adapter1ListTrangChu(
- MainFragment.this, R.layout.item_listtivi,
- listACate.get(0).channelList,0);
- gridTivi.setAdapter(adapter);
- gridTivi.setOnItemClickListener(onItemGridPhimClick);
- } catch (Exception e) {
- // TODO: handle exception
- e.printStackTrace();
- // MyLog.E(">>>>EEEEERRRRR");
- }
- } else {
- if (isLoaded)
- loadAllTrangChu();// cache
- else
- getAllTrangChu();
- }
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- public void showListTivi(ArrayList<obj1TiviK> listtivi) {
- slide(MyConstans.FRAG_LISTTIVI, true);
- showAdmob(false);
- try {
- adapter1ListTrangChu adapter = new adapter1ListTrangChu(
- MainFragment.this, R.layout.item_listtivi, listtivi,0);
- gridTivi.setAdapter(adapter);
- gridTivi.setOnItemClickListener(onItemGridPhimClick);
- } catch (Exception e) {
- // TODO: handle exception
- e.printStackTrace();
- // MyLog.E(">>>>EEEEERRRRR");
- }
- }
- private OnItemClickListener onItemGridPhimClick = new OnItemClickListener() {
- @Override
- public void onItemClick(AdapterView<?> parent, View view, int position,
- long arg3) {
- // Log.e("Menu","Click vao Menu");
- //showInterstitialAd();
- //startAppAd.showAd(); // show the ad
- //startAppAd.loadAd(); // load the next ad
- // TODO Auto-generated method stub
- obj1TiviK obj = (obj1TiviK) parent.getAdapter().getItem(position);
- playTivi(obj);
- }
- };
- private void showNEWS(obj1CateNo objcate) {
- slide(MyConstans.FRAG_NEWS, true);
- try {
- showAdmob(false);
- if(!isLoadedTheThao)
- getAllTheThao(objcate);
- // getAllTrangChu();
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- private void showLiveScore(obj1CateNo objcate) {
- slide(MyConstans.FRAG_SCORE, true);
- try {
- showAdmob(false);
- if(!isLoadedScore)
- getAllScore(objcate);
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- private void showWEBVIEW(obj1CateNo obj) {
- slide(MyConstans.FRAG_WEBVIEW, true);
- try {
- showAdmob(false);
- loadWebView(obj.description.replace("<p>", "").replace("</p>", ""));
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- private void loadWebView(String url) {
- final WebView mWebview = (WebView) view
- .findViewById(R.id.customize_webview);
- mWebview.getSettings().setJavaScriptEnabled(true); // enable javascript
- mWebview.getSettings().setLoadWithOverviewMode(true);
- mWebview.getSettings().setUseWideViewPort(true);
- mWebview.getSettings().setBuiltInZoomControls(true);
- mWebview.setWebViewClient(new WebViewClient() {
- public void onReceivedError(WebView view, int errorCode,
- String description, String failingUrl) {
- Toast.makeText(getActivity(), description, Toast.LENGTH_SHORT)
- .show();
- // llError.setVisibility(View.VISIBLE);
- // llLoading.setVisibility(View.GONE);
- }
- @Override
- public void onPageStarted(WebView view, String url, Bitmap favicon) {
- // pd.show();
- // llError.setVisibility(View.GONE);
- // llLoading.setVisibility(View.VISIBLE);
- mLoadWebview.setVisibility(View.VISIBLE);
- }
- @Override
- public void onPageFinished(WebView view, String url) {
- // pd.dismiss();
- // llError.setVisibility(View.GONE);
- // llLoading.setVisibility(View.GONE);
- // String webUrl = mWebview.getUrl();
- }
- });
- mWebview.setWebChromeClient(new WebChromeClient() {
- @Override
- public void onProgressChanged(WebView view, int newProgress) {
- // TODO Auto-generated method stub
- super.onProgressChanged(view, newProgress);
- if (newProgress >= 100) {
- // llError.setVisibility(View.GONE);
- // llLoading.setVisibility(View.GONE);
- mLoadWebview.setVisibility(View.GONE);
- } else {
- // llError.setVisibility(View.VISIBLE);
- // llLoading.setVisibility(View.VISIBLE);
- mLoadWebview.setVisibility(View.VISIBLE);
- }
- MyLog.E("newprogress>>>" + newProgress);
- }
- });
- mWebview.loadUrl(url);
- }
- public void playTivi(obj1TiviK obj) {
- // getActivity().startActivity(i);
- if (obj != null) {
- getVideo(obj);
- } else {
- Toast.makeText(getActivity(), "Error", Toast.LENGTH_SHORT).show();
- }
- }
- AsyncHttpClient client = new AsyncHttpClient();
- private void getVideo(final obj1TiviK obj){
- client.cancelRequests(getActivity(), true);
- client = new AsyncHttpClient();
- /// String video_id = "1FJHYqE0RDg";
- String video_id = "";
- String gdata = "http://gdata.youtube.com/feeds/api/videos/";
- String urlrequest = "";
- final String url = obj.urls;
- MyLog.E("url before>>>" + obj.urls);
- if(url.contains("youtube.com")){
- urlrequest = url;
- client.setUserAgent("Mozilla/5.0 (iPad; CPU OS 6_0_1 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A523 Safari/8536.25");
- MyLog.E("urlrequest youtube>>>" + urlrequest);
- if(myUtil.isInternet(getActivity()))
- client.get(urlrequest, new AsyncHttpResponseHandler() {
- @Override
- public void onStart() {
- // TODO Auto-generated method stub
- super.onStart();
- //progressLoading.setVisibility(View.VISIBLE);
- }
- @Override
- public void onSuccess(int arg0, String arg1) {
- // TODO Auto-generated method stub
- super.onSuccess(arg0, arg1);
- //progressLoading.setVisibility(View.GONE);
- //btnPlayPhim.setVisibility(View.VISIBLE);
- MyLog.E("You tube detail>>>" + arg1);
- try {
- Intent i = new Intent(getActivity(),CustomPlayVideo.class );
- // String rtsp_link = "rtsp:"+ MyUtil.split(MyUtil.split(arg1, "rtsp:")[1], ".3gp")[0] + ".3gp";
- String rtsp_link =MyUtil.getYoutubeRespond(arg1);
- MyLog.E("rtsp_link>>>" + rtsp_link);
- i.putExtra("URLPLAY", rtsp_link);
- i.putExtra("FILM_NAME", obj.channelName);
- getActivity().startActivity(i);
- } catch (Exception e) {
- // TODO: handle exception
- e.printStackTrace();
- }
- }
- @Override
- protected void sendFailureMessage(Throwable arg0, String arg1) {
- // TODO Auto-generated method stub
- super.sendFailureMessage(arg0, arg1);
- }
- });
- else
- Toast.makeText(getActivity(), "Error Network", Toast.LENGTH_SHORT).show();
- }else{
- //urlrequest = String.format(String.valueOf(MyConstans.API_PHIMDETAIL),obj.VideoId,url);
- //MyLog.E("url phimdetail>>>" + urlrequest);
- Intent i1 = new Intent(getActivity(), CustomPlayVideo.class);
- i1.putExtra("URLPLAY", obj.urls);
- i1.putExtra("FILM_NAME", obj.channelName);
- getActivity().startActivity(i1);
- }
- }
- private void slide(int newSlide, boolean n2c) {
- if (n2c && newSlide == currentScreen)
- return;
- viewFliper.setInAnimation(inFromRightAnimation());
- viewFliper.setOutAnimation(outToLeftAnimation());
- viewFliper.setDisplayedChild(newSlide);
- lastScreen = currentScreen;
- currentScreen = newSlide;
- }
- private Animation inFromRightAnimation() {
- Animation inFromRight = new TranslateAnimation(
- Animation.RELATIVE_TO_PARENT, +1.0f,
- Animation.RELATIVE_TO_PARENT, 0.0f,
- Animation.RELATIVE_TO_PARENT, 0.0f,
- Animation.RELATIVE_TO_PARENT, 0.0f);
- inFromRight.setDuration(000);// 500
- inFromRight.setInterpolator(new AccelerateInterpolator());
- return inFromRight;
- }
- private Animation outToLeftAnimation() {
- Animation outtoLeft = new TranslateAnimation(
- Animation.RELATIVE_TO_PARENT, 0.0f,
- Animation.RELATIVE_TO_PARENT, -1.0f,
- Animation.RELATIVE_TO_PARENT, 0.0f,
- Animation.RELATIVE_TO_PARENT, 0.0f);
- outtoLeft.setDuration(000);// 500
- outtoLeft.setInterpolator(new AccelerateInterpolator());
- return outtoLeft;
- }
- public void handerBackBottom() {
- if (currentScreen == MyConstans.FRAG_NEWS
- || currentScreen == MyConstans.FRAG_WEBVIEW || currentScreen == MyConstans.FRAG_LISTTIVI) {
- tvTitle.setText("HOME".toUpperCase());
- showTrangChu(null);
- } else
- quitGame();
- }
- public void quitGame() {
- AlertDialog.Builder editDialog = new AlertDialog.Builder(getActivity());
- editDialog.setTitle(getResources().getString(R.string.exit));
- editDialog.setMessage(getResources().getString(R.string.exit_question));
- editDialog.setIcon(R.drawable.logo_50);
- editDialog.setPositiveButton(getResources().getString(R.string.exit),
- new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int which) {
- //showInterstitialAd();
- // showInterstitialAd();
- // adBuddiz.showAd();
- // startAppAd.onBackPressed();
- startAppAd.showAd();
- getActivity().finish();
- //startAppAd.showAd(); // show the ad
- //startAppAd.s
- }
- });
- editDialog.setNegativeButton(getResources().getString(R.string.rate),
- new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int which) {
- Intent i = new Intent(
- Intent.ACTION_VIEW,
- Uri.parse("market://details?id="+ MyConstans.packagename));
- startActivity(i);
- }
- });
- editDialog.setNeutralButton(getResources().getString(R.string.skip),
- new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int which) {
- }
- });
- editDialog.show();
- }
- private void updateVersion() {
- AsyncHttpClient client = new AsyncHttpClient();
- String url = MyConstans.API_INFO;
- client.get(url, new AsyncHttpResponseHandler() {
- @Override
- public void onSuccess(int arg0, String request) {
- super.onSuccess(arg0, request);
- // MyLog.E("update" + request);
- JSONObject jsonObj;
- try {
- jsonObj = new JSONObject(request);
- String LinkDownload = "", versionName = "";
- int versionCode = -1;
- if (jsonObj != null) {
- LinkDownload = jsonObj.getString("LinkDownload");
- versionCode = jsonObj.getInt("versionCode");
- versionName = jsonObj.getString("versionName");
- MyConstans.packagename = jsonObj.getString("package");
- MyConstans.moreapp = jsonObj.getString("store");
- if (versionCode > getVersionApp()) // show dialog
- showDialogUpdate(versionName, LinkDownload);
- }
- } catch (JSONException e) {
- e.printStackTrace();
- }
- }
- @Override
- protected void sendFailureMessage(Throwable arg0, String arg1) {
- super.sendFailureMessage(arg0, arg1);
- }
- });
- }
- // get version code
- public int getVersionApp() {
- int v = 0;
- try {
- v = this.getActivity().getPackageManager()
- .getPackageInfo(this.getActivity().getPackageName(), 0).versionCode;
- } catch (NameNotFoundException e) {
- // Huh? Really?
- }
- return v;
- }
- // show dialog update
- public void showDialogUpdate(String versionName, final String urldownload) {
- AlertDialog.Builder editDialog = new AlertDialog.Builder(
- this.getActivity());
- editDialog.setTitle(getResources().getString(
- R.string.dialog_update_title));
- editDialog.setMessage(String.format(
- getResources().getString(R.string.dialog_update_content),
- versionName));
- editDialog.setPositiveButton("Yes",
- new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int which) {
- Intent i = new Intent(Intent.ACTION_VIEW, Uri
- .parse(urldownload));
- startActivity(i);
- }
- });
- editDialog.setNegativeButton("No",
- new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int which) {
- }
- });
- editDialog.show();
- }
- // //////
- private int currentScreen = -1;
- private int lastScreen = -1;
- private void getAllTrangChu() throws Exception {
- MyLog.E("loading" );
- View viewLoading = (View) view.findViewById(R.id.llTrangchuLoading);
- final View llError = (View) viewLoading
- .findViewById(R.id.loading_error);
- final View llLoading = (View) viewLoading
- .findViewById(R.id.loading_layout);
- llError.setVisibility(View.GONE);
- llLoading.setVisibility(View.GONE);
- AsyncHttpClient client = new AsyncHttpClient();
- String url = String.valueOf(MyConstans.API_TIVI_EN);
- if (Locale.getDefault().getLanguage().equals("vi"))
- {
- url = String.valueOf(MyConstans.API_TIVI_VN);
- }
- MyLog.E("Url tivi>>>" + url);
- // if (arrTrangChu.size() < 1)
- client.get(url, new AsyncHttpResponseHandler() {
- @Override
- public void onStart() {
- // TODO Auto-generated method stub
- super.onStart();
- mLoadWebview.setVisibility(View.VISIBLE);
- if (!myUtil.isInternet(getActivity()))
- llError.setVisibility(View.VISIBLE);
- else
- llLoading.setVisibility(View.VISIBLE);
- }
- @Override
- public void onSuccess(int arg0, String arg1) {
- // TODO Auto-generated method stub
- //MyLog.E("onSuccess()>>>");
- super.onSuccess(arg0, arg1);
- llLoading.setVisibility(View.GONE);
- MyLog.E("setVisibility()>>>");
- mLoadWebview.setVisibility(View.GONE);
- MyLog.E("phim trang chu>>>" + arg1);
- isLoaded = true;
- myData1.saveDataTrangChu(arg1);
- loadAllTrangChu();
- }
- @Override
- protected void sendFailureMessage(Throwable arg0, String arg1) {
- // TODO Auto-generated method stub
- super.sendFailureMessage(arg0, arg1);
- llLoading.setVisibility(View.GONE);
- llError.setVisibility(View.VISIBLE);
- }
- });
- }
- private void loadAllTrangChu() {
- try {
- arrTrangChu = new ArrayList<obj1ListChannel>();
- MyLog.E("data trang chu>>>" + myData1.getDataTrangChu());
- arrTrangChu = myUtil.getListChannel(myData1.getDataTrangChu());
- adapterTrangChu adapter = new adapterTrangChu(MainFragment.this,
- R.layout.item_trangchu, arrTrangChu);
- lvTrangChu.setAdapter(adapter);
- // create all listviti
- listAllTiviK = new ArrayList<obj1TiviK>();
- for (obj1ListChannel objitem : arrTrangChu) {
- for (obj1TiviK objTivi : objitem.channelList) {
- listAllTiviK.add(objTivi);
- }
- }
- // MyLog.E(">>>>size trang chu"+ arrTrangChu.size());
- } catch (Exception e) {
- // TODO: handle exception
- e.printStackTrace();
- // MyLog.E(">>>>EEEEERRRRR");
- }
- }
- private void getAllTheThao(obj1CateNo objcate) throws Exception {
- View viewLoading = (View) view.findViewById(R.id.llThethaoLoading);
- final View llError = (View) viewLoading
- .findViewById(R.id.loading_error);
- final View llLoading = (View) viewLoading
- .findViewById(R.id.loading_layout);
- llError.setVisibility(View.GONE);
- llLoading.setVisibility(View.GONE);
- AsyncHttpClient client = new AsyncHttpClient();
- String url = String.valueOf(objcate.description) ;
- client.get(url, new AsyncHttpResponseHandler() {
- @Override
- public void onStart() {
- // TODO Auto-generated method stub
- super.onStart();
- mLoadWebview.setVisibility(View.VISIBLE);
- if (!myUtil.isInternet(getActivity()))
- llError.setVisibility(View.VISIBLE);
- else
- llLoading.setVisibility(View.VISIBLE);
- }
- @Override
- public void onSuccess(int arg0, String arg1) {
- // TODO Auto-generated method stub
- super.onSuccess(arg0, arg1);
- llLoading.setVisibility(View.GONE);
- mLoadWebview.setVisibility(View.GONE);
- MyLog.E(" the thao>>>" + arg1);
- isLoadedTheThao = true;
- myData1.saveDataTheThao(arg1);
- loadingThethao();
- }
- @Override
- protected void sendFailureMessage(Throwable arg0, String arg1) {
- // TODO Auto-generated method stub
- super.sendFailureMessage(arg0, arg1);
- llLoading.setVisibility(View.GONE);
- llError.setVisibility(View.VISIBLE);
- }
- });
- }
- private void loadingThethao() {
- try {
- //init group and child
- groupList = new ArrayList<obj1ListTheThao>();
- thethaoCollection = new LinkedHashMap<obj1ListTheThao, ArrayList<obj1Thethao>>();
- groupList = myUtil.getListTheThao(myData1.getDataTheThao());
- for(obj1ListTheThao obj: groupList){
- thethaoCollection.put(obj, obj.listChiTiet);
- }
- final ExpandableListTheThaoAdapter expListAdapter = new ExpandableListTheThaoAdapter(
- MainFragment.this, groupList, thethaoCollection);
- expListViewTheThao.setAdapter(expListAdapter);
- expListViewTheThao.setOnChildClickListener(new OnChildClickListener() {
- public boolean onChildClick(ExpandableListView parent, View v,
- int groupPosition, int childPosition, long id) {
- final obj1Thethao FCitem = (obj1Thethao) expListAdapter.getChild(
- groupPosition, childPosition);
- // check to show tivi
- long current = MyUtil.createCurrentTimeStamp();
- MyLog.E("time>>>" + MyUtil.createTimeStamp());
- try {
- if (listAllTiviK != null) {
- obj1TiviK objNew = new obj1TiviK();
- for (obj1TiviK obj : listAllTiviK) {
- if (obj.channelId
- .contentEquals(FCitem.List_tvchannel_id))
- objNew = obj;
- }
- if (objNew != null)
- playTivi(objNew);
- }
- } catch (Exception e) {
- // TODO: handle exception
- }
- return true;
- }
- });
- // MyLog.E(">>>>size trang chu"+ arrTrangChu.size());
- } catch (Exception e) {
- // TODO: handle exception
- e.printStackTrace();
- // MyLog.E(">>>>EEEEERRRRR");
- }
- }
- //live score
- private void getAllScore(obj1CateNo objcate) throws Exception {
- View viewLoading = (View) view.findViewById(R.id.llLiveScore);
- final View llError = (View) viewLoading
- .findViewById(R.id.loading_error);
- final View llLoading = (View) viewLoading
- .findViewById(R.id.loading_layout);
- llError.setVisibility(View.GONE);
- llLoading.setVisibility(View.GONE);
- AsyncHttpClient client = new AsyncHttpClient();
- String url = String.valueOf(objcate.description) ;
- client.get(url, new AsyncHttpResponseHandler() {
- @Override
- public void onStart() {
- // TODO Auto-generated method stub
- super.onStart();
- mLoadWebview.setVisibility(View.VISIBLE);
- if (!myUtil.isInternet(getActivity()))
- llError.setVisibility(View.VISIBLE);
- else
- llLoading.setVisibility(View.VISIBLE);
- }
- @Override
- public void onSuccess(int arg0, String arg1) {
- // TODO Auto-generated method stub
- super.onSuccess(arg0, arg1);
- llLoading.setVisibility(View.GONE);
- mLoadWebview.setVisibility(View.GONE);
- MyLog.E("live score>>>" + arg1);
- isLoadedScore = true;
- myData1.saveDataLiveScore(arg1);
- loadingLiveScore();
- }
- @Override
- protected void sendFailureMessage(Throwable arg0, String arg1) {
- // TODO Auto-generated method stub
- super.sendFailureMessage(arg0, arg1);
- llLoading.setVisibility(View.GONE);
- llError.setVisibility(View.VISIBLE);
- }
- });
- }
- private void loadingLiveScore() {
- try {
- arrLiveScore = new ArrayList<obj1ListLiveScore>();
- liveScoreCollection = new LinkedHashMap<obj1ListLiveScore, ArrayList<obj1TranDau>>();
- arrLiveScore = myUtil.getLiveScore(myData1.getDataLiveScore());
- for(obj1ListLiveScore obj: arrLiveScore){
- liveScoreCollection.put(obj, obj.listTranDau);
- }
- final ExpandableListLiveScoreAdapter expListAdapter = new ExpandableListLiveScoreAdapter(
- MainFragment.this, arrLiveScore, liveScoreCollection);
- lvLiveScore.setAdapter(expListAdapter);
- lvLiveScore.setOnChildClickListener(new OnChildClickListener() {
- @Override
- public boolean onChildClick(ExpandableListView parent, View v,
- int groupPosition, int childPosition, long id) {
- // TODO Auto-generated method stub
- final obj1TranDau obj = (obj1TranDau) expListAdapter.getChild(
- groupPosition, childPosition);
- Intent i = new Intent(getActivity(), DetailLiveScore.class);
- i.putExtra("TranDauID", obj.TranDauID);
- i.putExtra("BanThangDoiBong1", obj.BanThangDoiBong1);
- i.putExtra("BanThangDoiBong2", obj.BanThangDoiBong2);
- i.putExtra("DoiBong1Full_Icon", obj.DoiBong1Full_Icon);
- i.putExtra("DoiBong2Full_Icon", obj.DoiBong2Full_Icon);
- i.putExtra("DoiBong1Full_TenDoiBong", obj.DoiBong1Full_TenDoiBong);
- i.putExtra("DoiBong2Full_TenDoiBong", obj.DoiBong2Full_TenDoiBong);
- getActivity().startActivity(i);
- return false;
- }
- });
- // arrLiveScore = new ArrayList<obj1TranDau>();
- // arrLiveScore = myUtil.getLiveScore(myData1.getDataLiveScore());
- // adapter1LiveScore adapter = new adapter1LiveScore(MainFragment.this, R.layout.item_1livescore, arrLiveScore);
- // lvLiveScore.setAdapter(adapter);
- // lvLiveScore.setOnItemClickListener(new OnItemClickListener() {
- //
- // @Override
- // public void onItemClick(AdapterView<?> parent, View arg1,
- // int position, long arg3) {
- // // TODO Auto-generated method stub
- // obj1TranDau obj = (obj1TranDau) parent.getAdapter().getItem(position);
- // Intent i = new Intent(getActivity(), DetailLiveScore.class);
- // i.putExtra("TranDauID", obj.TranDauID);
- // i.putExtra("BanThangDoiBong1", obj.BanThangDoiBong1);
- // i.putExtra("BanThangDoiBong2", obj.BanThangDoiBong2);
- // i.putExtra("DoiBong1Full_Icon", obj.DoiBong1Full_Icon);
- // i.putExtra("DoiBong2Full_Icon", obj.DoiBong2Full_Icon);
- // i.putExtra("DoiBong1Full_TenDoiBong", obj.DoiBong1Full_TenDoiBong);
- // i.putExtra("DoiBong2Full_TenDoiBong", obj.DoiBong2Full_TenDoiBong);
- // getActivity().startActivity(i);
- //
- // }
- // });
- // MyLog.E(">>>>size trang chu"+ arrTrangChu.size());
- } catch (Exception e) {
- // TODO: handle exception
- e.printStackTrace();
- // MyLog.E(">>>>EEEEERRRRR");
- }
- }
- @Override
- public void onDestroy() {
- // TODO Auto-generated method stub
- super.onDestroy();
- myData.close();
- }
- // start app
- private StartAppAd startAppAd;
- private void iniStartApp() {
- //if (MyUtil.isShowAds) {
- // StartAppSearch.init(getActivity());
- startAppAd = new StartAppAd(getActivity());
- //}
- }
- @Override
- public void onResume() {
- super.onResume();
- // if (MyUtil.isShowAds)
- // startAppAd.onResume();
- AdIDManager.addtoParent(adview);
- // adBuddiz.onStart(getActivity());
- }
- private InterstitialAd interstitialAd;
- // private final static String interstitialKey = "ca-app-pub-9820030150756925/5059024695";//"b99ec229ebcc49ea";
- private void requestAds() {
- interstitialAd.loadAd(new AdRequest.Builder().build());
- }
- private void initInterstitialAds(){
- interstitialAd = new InterstitialAd(getActivity());
- interstitialAd.setAdUnitId(MyConstans.ADDMOD_POPUP_ID);
- interstitialAd.setAdListener(new AdIDListener(getActivity()){
- public void onAdLoaded() {
- // TODO Auto-generated method stub
- super.onAdLoaded();
- Log.e("interstitialAd",
- "onAdLoaded");
- }
- @Override
- public void onAdFailedToLoad(int errorCode) {
- // TODO Auto-generated method stub
- super.onAdFailedToLoad(errorCode);
- requestAds();
- Log.e("interstitialAd",
- "onAdFailedToLoad");
- }
- @Override
- public void onAdOpened() {
- // TODO Auto-generated method stub
- super.onAdOpened();
- Log.e("interstitialAd",
- "onAdOpened");
- }
- @Override
- public void onAdClosed() {
- // TODO Auto-generated method stub
- super.onAdClosed();
- requestAds();
- //showHighscore();
- Log.e("interstitialAd",
- "onAdClosed");
- }
- @Override
- public void onAdLeftApplication() {
- // TODO Auto-generated method stub
- super.onAdLeftApplication();
- Log.e("interstitialAd",
- "onAdLeftApplication");
- }
- });
- requestAds();
- }
- private void showInterstitialAd() {
- if (interstitialAd.isLoaded()) {
- Log.e("Menu","Menu");
- interstitialAd.show();
- }else{
- Log.e("interstitialAd",
- "Interstitial ad was not ready to be shown.");
- //showHighscore();
- }
- }
- private void showAdmob(boolean ishow) {
- adview.setVisibility(View.VISIBLE);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment