Skip to content

Commit

Permalink
add ad to SearchActivity
Browse files Browse the repository at this point in the history
  • Loading branch information
HumbleLivelyBear2 committed Apr 6, 2013
1 parent 76258c0 commit cca9adc
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 3 deletions.
3 changes: 2 additions & 1 deletion AndroidManifest.xml
Expand Up @@ -44,7 +44,8 @@
<activity
android:name=".SearchActivity"
android:configChanges="keyboardHidden|orientation"
android:screenOrientation="portrait"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustPan"
>
</activity>
<activity
Expand Down
11 changes: 10 additions & 1 deletion src/com/ptt/food/blog/ArticleActivity.java
Expand Up @@ -13,6 +13,8 @@
import android.os.AsyncTask;
import android.os.Bundle;
import android.text.Html;
import android.text.method.LinkMovementMethod;
import android.text.util.Linkify;
import android.view.Display;
import android.view.View;
import android.view.View.OnClickListener;
Expand Down Expand Up @@ -171,7 +173,8 @@ private void setViews() {
articleTextView.setTextSize(textContentSize);

webArticle = (WebView) findViewById (R.id.web_article);
webArticle.getSettings().setSupportZoom(true);
webArticle.getSettings().setSupportZoom(true);
// webArticle.getSettings().setBuiltInZoomControls(true);
webArticle.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
webArticle.setWebViewClient(new WebViewClient());
webArticle.setVisibility(View.GONE);
Expand Down Expand Up @@ -434,6 +437,12 @@ protected void onPostExecute(Void result) {
private void setUIAfterLoading() {

articleTextView.setText(myAricle.getContent());
Linkify.addLinks(articleTextView, Linkify.ALL);


// articleTextView.setText("Test Test"+Html.fromHtml(
// myAricle.getContent()));
// articleTextView.setMovementMethod(LinkMovementMethod.getInstance());

String text = "<font color=#9E1919>"+myAricle.getTitle()+"</font>"+ "<font color=#AD8440>"+" by "+myAricle.getAuthor()+"</font>";
articleTextTitle.setText(Html.fromHtml(text));
Expand Down
72 changes: 71 additions & 1 deletion src/com/ptt/food/blog/SearchActivity.java
Expand Up @@ -12,8 +12,11 @@
import android.os.AsyncTask;
import android.os.Bundle;
import android.text.InputType;
import android.view.Display;
import android.view.KeyEvent;
import android.view.View;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.Animation;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodManager;
import android.widget.AdapterView;
Expand All @@ -27,14 +30,20 @@
import com.actionbarsherlock.app.SherlockActivity;
import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuItem;
import com.adwhirl.AdWhirlLayout;
import com.adwhirl.AdWhirlManager;
import com.adwhirl.AdWhirlTargeting;
import com.adwhirl.AdWhirlLayout.AdWhirlInterface;
import com.costum.android.widget.LoadMoreListView;
import com.costum.android.widget.LoadMoreListView.OnLoadMoreListener;
import com.google.ads.AdView;
import com.kosbrother.tool.DetectScrollView.DetectScrollViewListener;
import com.ptt.food.blog.api.DBAPI;
import com.ptt.food.blog.api.PttFoodAPI;
import com.ptt.food.blog.entity.Article;
import com.taiwan.imageload.ListArticleAdapter;

public class SearchActivity extends SherlockActivity {
public class SearchActivity extends SherlockActivity implements AdWhirlInterface{

private static final int Contact_US = 0;
private static final int ID_ABOUT_US = 1;
Expand All @@ -56,6 +65,8 @@ public class SearchActivity extends SherlockActivity {
private LinearLayout layoutNoSearch;
private AlertDialog.Builder aboutUsDialog;
private ListArticleAdapter myListAdapter;

private final String adWhirlKey = "5dc7684994954d51add2cd7b0768f564";

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand Down Expand Up @@ -101,6 +112,18 @@ public void onLoadMore() {

favoriteArticles = DBAPI.getAllArticles(SearchActivity.this);
new LoadDataTask().execute();

try {
Display display = getWindowManager().getDefaultDisplay();
int width = display.getWidth(); // deprecated
int height = display.getHeight(); // deprecated

if (width > 320) {
setAdAdwhirl();
}
} catch (Exception e) {

}
}


Expand Down Expand Up @@ -309,6 +332,53 @@ public void onResume() {
myListAdapter.notifyDataSetChanged();
}
}

private void setAdAdwhirl() {
// TODO Auto-generated method stub
AdWhirlManager.setConfigExpireTimeout(1000 * 60);
AdWhirlTargeting.setAge(23);
AdWhirlTargeting.setGender(AdWhirlTargeting.Gender.MALE);
AdWhirlTargeting.setKeywords("online games gaming");
AdWhirlTargeting.setPostalCode("94123");
AdWhirlTargeting.setTestMode(false);

AdWhirlLayout adwhirlLayout = new AdWhirlLayout(this, adWhirlKey);

LinearLayout mainLayout = (LinearLayout) findViewById(R.id.adonView);

adwhirlLayout.setAdWhirlInterface(this);

mainLayout.addView(adwhirlLayout);

mainLayout.invalidate();
}

@Override
public void adWhirlGeneric() {
// TODO Auto-generated method stub

}

public void rotationHoriztion(int beganDegree, int endDegree, AdView view) {
final float centerX = 320 / 2.0f;
final float centerY = 48 / 2.0f;
final float zDepth = -0.50f * view.getHeight();

Rotate3dAnimation rotation = new Rotate3dAnimation(beganDegree, endDegree, centerX, centerY, zDepth, true);
rotation.setDuration(1000);
rotation.setInterpolator(new AccelerateInterpolator());
rotation.setAnimationListener(new Animation.AnimationListener() {
public void onAnimationStart(Animation animation) {
}

public void onAnimationEnd(Animation animation) {
}

public void onAnimationRepeat(Animation animation) {
}
});
view.startAnimation(rotation);
}


}

0 comments on commit cca9adc

Please sign in to comment.