Created
June 18, 2012 12:00
-
-
Save lukaspili/2948038 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
android:orientation="vertical" | |
android:layout_width="fill_parent" | |
android:layout_height="fill_parent"> | |
<com.smartadserver.android.library.SASBannerView | |
android:id="@+id/sas_banner" | |
android:layout_width="fill_parent" | |
android:layout_height="53dp" | |
android:visibility="visible"/> | |
<ListView | |
android:id="@android:id/list" | |
android:layout_width="fill_parent" | |
android:layout_height="fill_parent" | |
android:background="@android:color/white"/> | |
</LinearLayout> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class BanniereFragment extends Fragment { | |
private SASBannerView sasBannerView; | |
@Override | |
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { | |
View view = inflater.inflate(R.layout.banniere, container, false); | |
sasBannerView = (SASBannerView) view.findViewById(R.id.sas_banner); | |
return view; | |
} | |
@Override | |
public void onActivityCreated(Bundle savedInstanceState) { | |
super.onActivityCreated(savedInstanceState); | |
View loader = new SASRotatingImageLoader(getActivity()); | |
loader.setBackgroundColor(0x66000000); | |
sasBannerView.setLoaderView(loader); | |
boolean pro = (null != DataAccessLayer.getInstance().getUser() && DataAccessLayer.getInstance().getUser().getType() == User.Type.PRO) ? true : false; | |
int pageId; | |
if (DataAccessLayer.getInstance().getMenuItem() == Universe.MEDICINE) { | |
pageId = pro ? R.string.smartadserver_pageid_banner_pro_medicine : R.string.smartadserver_pageid_banner_public_medicine; | |
} else { | |
pageId = pro ? R.string.smartadserver_pageid_banner_pro_pharmacy : R.string.smartadserver_pageid_banner_public_pharmacy; | |
} | |
Log.d(getClass().getName(), "SmartAdServer banner page id : " + getString(pageId)); | |
sasBannerView.loadAd(getResources().getInteger(R.integer.smartadserver_siteid), getString(pageId), R.integer.smartadserver_formatid_banner, true); | |
} | |
@Override | |
public void onDestroy() { | |
super.onDestroy(); | |
if (null != sasBannerView) { | |
sasBannerView.onDestroy(); | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class InterstitielActivity extends Activity { | |
private CheckBox checkBox; | |
private SASInterstitialView sasInterstitialView; | |
@Override | |
public void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.universe_activity); | |
showSas(); | |
} | |
@Override | |
protected void onDestroy() { | |
super.onDestroy(); | |
sasInterstitialView.onDestroy(); | |
} | |
private void showSas() { | |
sasInterstitialView = new SASInterstitialView(this); | |
sasInterstitialView.setBackgroundColor(0xCCCCCC); | |
View loader = new SASRotatingImageLoader(this); | |
loader.setBackgroundColor(0xCCCCCC); | |
sasInterstitialView.setLoaderView(loader); | |
sasInterstitialView.addStateChangeListener(new SASAdView.OnStateChangeListener() { | |
public void onStateChanged(SASAdView.StateChangeEvent stateChangeEvent) { | |
switch(stateChangeEvent.getType()) { | |
case SASAdView.StateChangeEvent.VIEW_HIDDEN: | |
loadNextActivity(); | |
break; | |
} | |
} | |
}); | |
boolean pro = (null != DataAccessLayer.getInstance().getUser() && DataAccessLayer.getInstance().getUser().getType() == User.Type.PRO) ? true : false; | |
int pageId; | |
if (DataAccessLayer.getInstance().getMenuItem() == Universe.MEDICINE) { | |
pageId = pro ? R.string.smartadserver_pageid_intersitiel_pro_medicine : R.string.smartadserver_pageid_intersitiel_public_medicine; | |
} else { | |
pageId = pro ? R.string.smartadserver_pageid_intersitiel_pro_pharmacy : R.string.smartadserver_pageid_intersitiel_public_pharmacy; | |
} | |
Log.d(getClass().getName(), "SmartAdServer intersistiel page id : " + getString(pageId)); | |
sasInterstitialView.loadAd(getResources().getInteger(R.integer.smartadserver_siteid), getString(pageId), R.integer.smartadserver_formatid_interstitiel, true, "", new SASAdView.AdResponseHandler() { | |
@Override | |
public void adLoadingCompleted(SASAdElement sasAdElement) { | |
} | |
@Override | |
public void adLoadingFailed(Exception e) { | |
loadNextActivity(); | |
} | |
}); | |
} | |
private void loadNextActivity() { | |
if (DataAccessLayer.getInstance().getMenuItem() == null) { | |
return; | |
} | |
if (null != checkBox && checkBox.isChecked()) { | |
new UniverseService().save(DataAccessLayer.getInstance().getMenuItem()); | |
} | |
Intent intent = new Intent(); | |
intent.setClass(this, LoginActivity.class); | |
startActivity(intent); | |
finish(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment