Skip to content

Commit

Permalink
get rid of app compact and set share Intent
Browse files Browse the repository at this point in the history
  • Loading branch information
yelinaung committed Sep 25, 2014
1 parent 5c10ca0 commit 8953b12
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 34 deletions.
3 changes: 3 additions & 0 deletions .idea/misc.xml

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

1 change: 0 additions & 1 deletion app/app.iml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@
</content>
<orderEntry type="jdk" jdkName="Android API 20 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="appcompat-v7-20.0.0" level="project" />
<orderEntry type="library" exported="" name="support-annotations-20.0.0" level="project" />
<orderEntry type="library" exported="" name="support-v4-20.0.0" level="project" />
</component>
Expand Down
1 change: 0 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,4 @@ android {
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v4:20.0.0'
compile 'com.android.support:appcompat-v7:20.0.0'
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@

import android.app.Activity;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.Menu;
import android.view.MenuItem;


public class DetailActivity extends ActionBarActivity {
public class DetailActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand Down
31 changes: 15 additions & 16 deletions app/src/main/java/com/androidbootcamp/sunshine/DetailFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import android.app.Fragment;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.view.MenuItemCompat;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
Expand All @@ -23,6 +21,8 @@ public class DetailFragment extends Fragment {
public String mForecastStr;
public static final String LOG_TAG = DetailFragment.class.getSimpleName();

private ShareActionProvider mShareActionProvider;

public DetailFragment() {
setHasOptionsMenu(true);
}
Expand All @@ -43,24 +43,23 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
//inflate the menu. This adds the menu item to the ActionBar
// inflate the menu. This adds the menu item to the ActionBar
inflater.inflate(R.menu.detail_fragment, menu);
/*
//Retrieve the share menu item
*/
// Retrieve the share menu item
MenuItem item = menu.findItem(R.id.menu_item_share);
//fetch and store the ActionProvider
android.support.v7.widget.ShareActionProvider mShareActionProvider =
(android.support.v7.widget.ShareActionProvider) MenuItemCompat.getActionProvider(item);
//Attach the intent to the ActionProvider. You can update this at any time.
//like when users select a new piece of data they'd like to share
// fetch and store the ActionProvider
mShareActionProvider =
(ShareActionProvider) item.getActionProvider();
// Attach the intent to the ActionProvider. You can update this at any time.
// like when users select a new piece of data they'd like to share
setShareIntent(createShareForecastIntent());
super.onCreateOptionsMenu(menu, inflater);
}

private void setShareIntent(Intent shareIntent) {
if (mShareActionProvider != null) {
mShareActionProvider.setShareIntent(createShareForecastIntent());
Log.d(LOG_TAG, "Setting share intent");
} else {
Log.d(LOG_TAG, "Share Action Provider is null");
mShareActionProvider.setShareIntent(shareIntent);
}
super.onCreateOptionsMenu(menu, inflater);
}


Expand Down

This file was deleted.

10 changes: 4 additions & 6 deletions app/src/main/res/menu/detail_fragment.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>

<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<menu xmlns:android="http://schemas.android.com/apk/res/android">

<item
android:id="@+id/menu_item_share"
android:title="@string/action_share"
app:showAsAction="always"
app:actionProviderClass="android.support.v7.widget.ShareActionProvider"
/>
android:actionProviderClass="android.widget.ShareActionProvider"
android:showAsAction="always"
android:title="@string/action_share" />
</menu>
2 changes: 1 addition & 1 deletion app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<resources>

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar">
<!-- Customize your theme here. -->
</style>

Expand Down

0 comments on commit 8953b12

Please # to comment.