Skip to content

Commit

Permalink
[Update] updating sample app
Browse files Browse the repository at this point in the history
  • Loading branch information
mzelzoghbi committed Dec 31, 2016
1 parent 47394dd commit 9343d87
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,8 @@ dependencies {
testCompile 'junit:junit:4.12'
compile "com.android.support:appcompat-v7:$rootProject.ext.supportLibVersion"
compile project(':zgallery')

compile "com.google.firebase:firebase-ads:$rootProject.ext.adsVersion"

}

28 changes: 28 additions & 0 deletions app/src/main/java/com/mzelzoghbi/sample/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
import android.support.v7.widget.Toolbar;
import android.view.View;

import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdView;
import com.google.android.gms.ads.InterstitialAd;
import com.google.android.gms.ads.MobileAds;
import com.mzelzoghbi.zgallery.ZGallery;
import com.mzelzoghbi.zgallery.ZGrid;
import com.mzelzoghbi.zgallery.entities.ZColor;
Expand All @@ -14,6 +18,7 @@
public class MainActivity extends AppCompatActivity {

private Toolbar toolbar;
private InterstitialAd mInterstitialAd;

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand All @@ -23,6 +28,29 @@ protected void onCreate(Bundle savedInstanceState) {
toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);

// init sdk
MobileAds.initialize(getApplicationContext(), getString(R.string.ad_mob_id));
// init banner
AdView mAdView = (AdView) findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder()
.build();
mAdView.loadAd(adRequest);
// init interstital
mInterstitialAd = new InterstitialAd(this);
mInterstitialAd.setAdUnitId(getString(R.string.ad_mob_interstitial));

AdRequest interstitialAdRequest = new AdRequest.Builder()
.build();

mInterstitialAd.loadAd(interstitialAdRequest);
}

@Override
protected void onResume() {
super.onResume();
if (mInterstitialAd.isLoaded()) {
mInterstitialAd.show();
}
}

public void gridActivity(View v) {
Expand Down
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/ic_directory.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="25dp"
android:height="36dp"
android:viewportHeight="36.0"
android:viewportWidth="25.0">
<path
android:fillColor="#FF000000"
android:pathData="M24.238,9.113C24.111,8.637 23.854,8.13 23.663,7.686C21.383,2.203 16.402,0.238 12.38,0.238C6.995,0.238 1.065,3.852 0.273,11.299L0.273,12.821C0.273,12.884 0.295,13.455 0.326,13.74C0.77,17.289 3.568,21.062 5.658,24.611C7.907,28.414 10.241,32.155 12.553,35.894C13.978,33.454 15.398,30.982 16.791,28.604C17.171,27.907 17.612,27.21 17.992,26.544C18.245,26.101 18.729,25.657 18.95,25.245C21.199,21.125 24.818,16.973 24.818,12.884L24.818,11.205C24.818,10.761 24.27,9.208 24.238,9.113ZM12.478,16.751C10.895,16.751 9.163,15.959 8.308,13.772C8.18,13.424 8.191,12.726 8.191,12.662L8.191,11.68C8.191,8.891 10.557,7.623 12.615,7.623C15.149,7.623 17.108,9.652 17.108,12.187C17.108,14.723 15.012,16.751 12.478,16.751Z" />
</vector>
28 changes: 21 additions & 7 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
tools:context="com.mzelzoghbi.sample.MainActivity">

Expand All @@ -13,21 +14,34 @@
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:fitsSystemWindows="true"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:minHeight="?attr/actionBarSize" />
android:minHeight="?attr/actionBarSize"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />

<Button
android:layout_margin="@dimen/normal"
android:id="@+id/gridActivityBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/toolbar"
android:layout_margin="@dimen/normal"
android:onClick="gridActivity"
android:text="Grid Activity" />

<Button
android:id="@+id/galleryActivityBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/normal"
android:layout_below="@+id/gridActivityBtn"
android:layout_marginLeft="@dimen/normal"
android:layout_marginTop="@dimen/normal"
android:onClick="galleryActivity"
android:text="Gallery Activity" />
</LinearLayout>

<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
ads:adSize="BANNER"
ads:adUnitId="@string/ad_mob_banner" />
</RelativeLayout>
4 changes: 4 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
<resources>
<string name="app_name">ZGallery</string>

<string name="ad_mob_id">ca-app-pub-6284699558538127~1735568290</string>
<string name="ad_mob_banner">ca-app-pub-6284699558538127/4689034694</string>
<string name="ad_mob_interstitial">ca-app-pub-6284699558538127/6165767895</string>
</resources>
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.2'
classpath 'com.android.tools.build:gradle:2.2.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
Expand All @@ -32,4 +32,5 @@ ext {
supportLibVersion = "25.0.1"
glideVersion = "3.7.0"
photoViewLibVersion = "1.3.0"
adsVersion = "10.0.1"
}

0 comments on commit 9343d87

Please sign in to comment.