am 402d3fd4: am 41867b63: Merge "Fix the support-v4 demos to work on a platform with APIs V4 (samples part)" into ics-mr1
* commit '402d3fd41838dc6a098ec3482f83b20b32df29f4': Fix the support-v4 demos to work on a platform with APIs V4 (samples part)
This commit is contained in:
@@ -22,7 +22,7 @@ import android.support.v4.app.Fragment;
|
|||||||
import android.support.v4.app.FragmentActivity;
|
import android.support.v4.app.FragmentActivity;
|
||||||
import android.support.v4.app.FragmentManager;
|
import android.support.v4.app.FragmentManager;
|
||||||
import android.support.v4.app.FragmentTransaction;
|
import android.support.v4.app.FragmentTransaction;
|
||||||
import android.support.v4.view.MenuCompat;
|
import android.support.v4.view.MenuItemCompat;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
@@ -112,9 +112,9 @@ public class FragmentMenuSupport extends FragmentActivity {
|
|||||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||||
MenuItem item;
|
MenuItem item;
|
||||||
item = menu.add("Menu 1a");
|
item = menu.add("Menu 1a");
|
||||||
MenuCompat.setShowAsAction(item, MenuItem.SHOW_AS_ACTION_IF_ROOM);
|
MenuItemCompat.setShowAsAction(item, MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);
|
||||||
item = menu.add("Menu 1b");
|
item = menu.add("Menu 1b");
|
||||||
MenuCompat.setShowAsAction(item, MenuItem.SHOW_AS_ACTION_IF_ROOM);
|
MenuItemCompat.setShowAsAction(item, MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -133,7 +133,7 @@ public class FragmentMenuSupport extends FragmentActivity {
|
|||||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||||
MenuItem item;
|
MenuItem item;
|
||||||
item = menu.add("Menu 2");
|
item = menu.add("Menu 2");
|
||||||
MenuCompat.setShowAsAction(item, MenuItem.SHOW_AS_ACTION_IF_ROOM);
|
MenuItemCompat.setShowAsAction(item, MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,8 +40,8 @@ public class FragmentReceiveResultSupport extends FragmentActivity {
|
|||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(
|
FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(
|
||||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
ViewGroup.LayoutParams.FILL_PARENT,
|
||||||
ViewGroup.LayoutParams.MATCH_PARENT);
|
ViewGroup.LayoutParams.FILL_PARENT);
|
||||||
FrameLayout frame = new FrameLayout(this);
|
FrameLayout frame = new FrameLayout(this);
|
||||||
frame.setId(R.id.simple_fragment);
|
frame.setId(R.id.simple_fragment);
|
||||||
setContentView(frame, lp);
|
setContentView(frame, lp);
|
||||||
|
|||||||
@@ -22,16 +22,21 @@ import android.support.v4.app.ListFragment;
|
|||||||
import android.support.v4.app.LoaderManager;
|
import android.support.v4.app.LoaderManager;
|
||||||
import android.support.v4.content.CursorLoader;
|
import android.support.v4.content.CursorLoader;
|
||||||
import android.support.v4.content.Loader;
|
import android.support.v4.content.Loader;
|
||||||
|
import android.support.v4.view.MenuItemCompat;
|
||||||
|
import android.support.v4.widget.SearchViewCompat;
|
||||||
|
import android.support.v4.widget.SearchViewCompat.OnQueryTextListenerCompat;
|
||||||
import android.support.v4.widget.SimpleCursorAdapter;
|
import android.support.v4.widget.SimpleCursorAdapter;
|
||||||
|
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.provider.ContactsContract.Contacts;
|
import android.provider.BaseColumns;
|
||||||
|
import android.provider.Contacts.People;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuInflater;
|
import android.view.MenuInflater;
|
||||||
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
|
|
||||||
@@ -39,6 +44,7 @@ import android.widget.ListView;
|
|||||||
* Demonstration of the use of a CursorLoader to load and display contacts
|
* Demonstration of the use of a CursorLoader to load and display contacts
|
||||||
* data in a fragment.
|
* data in a fragment.
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("all")
|
||||||
public class LoaderCursorSupport extends FragmentActivity {
|
public class LoaderCursorSupport extends FragmentActivity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -76,9 +82,9 @@ public class LoaderCursorSupport extends FragmentActivity {
|
|||||||
|
|
||||||
// Create an empty adapter we will use to display the loaded data.
|
// Create an empty adapter we will use to display the loaded data.
|
||||||
mAdapter = new SimpleCursorAdapter(getActivity(),
|
mAdapter = new SimpleCursorAdapter(getActivity(),
|
||||||
android.R.layout.simple_list_item_2, null,
|
android.R.layout.simple_list_item_1, null,
|
||||||
new String[] { Contacts.DISPLAY_NAME, Contacts.CONTACT_STATUS },
|
new String[] { People.DISPLAY_NAME },
|
||||||
new int[] { android.R.id.text1, android.R.id.text2 }, 0);
|
new int[] { android.R.id.text1}, 0);
|
||||||
setListAdapter(mAdapter);
|
setListAdapter(mAdapter);
|
||||||
|
|
||||||
// Start out with a progress indicator.
|
// Start out with a progress indicator.
|
||||||
@@ -91,21 +97,25 @@ public class LoaderCursorSupport extends FragmentActivity {
|
|||||||
|
|
||||||
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||||
// Place an action bar item for searching.
|
// Place an action bar item for searching.
|
||||||
//MenuItem item = menu.add("Search");
|
MenuItem item = menu.add("Search");
|
||||||
//item.setIcon(android.R.drawable.ic_menu_search);
|
item.setIcon(android.R.drawable.ic_menu_search);
|
||||||
//item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
|
MenuItemCompat.setShowAsAction(item, MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
|
||||||
//SearchView sv = new SearchView(getActivity());
|
View searchView = SearchViewCompat.newSearchView(getActivity());
|
||||||
//sv.setOnQueryTextListener(this);
|
if (searchView != null) {
|
||||||
//item.setActionView(sv);
|
SearchViewCompat.setOnQueryTextListener(searchView,
|
||||||
}
|
new OnQueryTextListenerCompat() {
|
||||||
|
@Override
|
||||||
public boolean onQueryTextChange(String newText) {
|
public boolean onQueryTextChange(String newText) {
|
||||||
// Called when the action bar search text has changed. Update
|
// Called when the action bar search text has changed. Update
|
||||||
// the search filter, and restart the loader to do a new query
|
// the search filter, and restart the loader to do a new query
|
||||||
// with this filter.
|
// with this filter.
|
||||||
mCurFilter = !TextUtils.isEmpty(newText) ? newText : null;
|
mCurFilter = !TextUtils.isEmpty(newText) ? newText : null;
|
||||||
getLoaderManager().restartLoader(0, null, this);
|
getLoaderManager().restartLoader(0, null, CursorLoaderListFragment.this);
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
MenuItemCompat.setActionView(item, searchView);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void onListItemClick(ListView l, View v, int position, long id) {
|
@Override public void onListItemClick(ListView l, View v, int position, long id) {
|
||||||
@@ -115,12 +125,8 @@ public class LoaderCursorSupport extends FragmentActivity {
|
|||||||
|
|
||||||
// These are the Contacts rows that we will retrieve.
|
// These are the Contacts rows that we will retrieve.
|
||||||
static final String[] CONTACTS_SUMMARY_PROJECTION = new String[] {
|
static final String[] CONTACTS_SUMMARY_PROJECTION = new String[] {
|
||||||
Contacts._ID,
|
People._ID,
|
||||||
Contacts.DISPLAY_NAME,
|
People.DISPLAY_NAME,
|
||||||
Contacts.CONTACT_STATUS,
|
|
||||||
Contacts.CONTACT_PRESENCE,
|
|
||||||
Contacts.PHOTO_ID,
|
|
||||||
Contacts.LOOKUP_KEY,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
|
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
|
||||||
@@ -130,20 +136,18 @@ public class LoaderCursorSupport extends FragmentActivity {
|
|||||||
// currently filtering.
|
// currently filtering.
|
||||||
Uri baseUri;
|
Uri baseUri;
|
||||||
if (mCurFilter != null) {
|
if (mCurFilter != null) {
|
||||||
baseUri = Uri.withAppendedPath(Contacts.CONTENT_FILTER_URI,
|
baseUri = Uri.withAppendedPath(People.CONTENT_FILTER_URI, Uri.encode(mCurFilter));
|
||||||
Uri.encode(mCurFilter));
|
|
||||||
} else {
|
} else {
|
||||||
baseUri = Contacts.CONTENT_URI;
|
baseUri = People.CONTENT_URI;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now create and return a CursorLoader that will take care of
|
// Now create and return a CursorLoader that will take care of
|
||||||
// creating a Cursor for the data being displayed.
|
// creating a Cursor for the data being displayed.
|
||||||
String select = "((" + Contacts.DISPLAY_NAME + " NOTNULL) AND ("
|
String select = "((" + People.DISPLAY_NAME + " NOTNULL) AND ("
|
||||||
+ Contacts.HAS_PHONE_NUMBER + "=1) AND ("
|
+ People.DISPLAY_NAME + " != '' ))";
|
||||||
+ Contacts.DISPLAY_NAME + " != '' ))";
|
|
||||||
return new CursorLoader(getActivity(), baseUri,
|
return new CursorLoader(getActivity(), baseUri,
|
||||||
CONTACTS_SUMMARY_PROJECTION, select, null,
|
CONTACTS_SUMMARY_PROJECTION, select, null,
|
||||||
Contacts.DISPLAY_NAME + " COLLATE LOCALIZED ASC");
|
People.DISPLAY_NAME + " COLLATE LOCALIZED ASC");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
|
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
|
||||||
|
|||||||
@@ -16,15 +16,6 @@
|
|||||||
|
|
||||||
package com.example.android.supportv4.app;
|
package com.example.android.supportv4.app;
|
||||||
|
|
||||||
import com.example.android.supportv4.R;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.text.Collator;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
@@ -41,7 +32,12 @@ import android.support.v4.app.FragmentManager;
|
|||||||
import android.support.v4.app.ListFragment;
|
import android.support.v4.app.ListFragment;
|
||||||
import android.support.v4.app.LoaderManager;
|
import android.support.v4.app.LoaderManager;
|
||||||
import android.support.v4.content.AsyncTaskLoader;
|
import android.support.v4.content.AsyncTaskLoader;
|
||||||
|
import android.support.v4.content.IntentCompat;
|
||||||
import android.support.v4.content.Loader;
|
import android.support.v4.content.Loader;
|
||||||
|
import android.support.v4.content.pm.ActivityInfoCompat;
|
||||||
|
import android.support.v4.view.MenuItemCompat;
|
||||||
|
import android.support.v4.widget.SearchViewCompat;
|
||||||
|
import android.support.v4.widget.SearchViewCompat.OnQueryTextListenerCompat;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
@@ -53,9 +49,16 @@ import android.view.ViewGroup;
|
|||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.SearchView;
|
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.SearchView.OnQueryTextListener;
|
|
||||||
|
import com.example.android.supportv4.R;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.text.Collator;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Demonstration of the implementation of a custom Loader.
|
* Demonstration of the implementation of a custom Loader.
|
||||||
@@ -166,7 +169,7 @@ public class LoaderCustomSupport extends FragmentActivity {
|
|||||||
int configChanges = mLastConfiguration.updateFrom(res.getConfiguration());
|
int configChanges = mLastConfiguration.updateFrom(res.getConfiguration());
|
||||||
boolean densityChanged = mLastDensity != res.getDisplayMetrics().densityDpi;
|
boolean densityChanged = mLastDensity != res.getDisplayMetrics().densityDpi;
|
||||||
if (densityChanged || (configChanges&(ActivityInfo.CONFIG_LOCALE
|
if (densityChanged || (configChanges&(ActivityInfo.CONFIG_LOCALE
|
||||||
|ActivityInfo.CONFIG_UI_MODE|ActivityInfo.CONFIG_SCREEN_LAYOUT)) != 0) {
|
|ActivityInfoCompat.CONFIG_UI_MODE|ActivityInfo.CONFIG_SCREEN_LAYOUT)) != 0) {
|
||||||
mLastDensity = res.getDisplayMetrics().densityDpi;
|
mLastDensity = res.getDisplayMetrics().densityDpi;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -190,8 +193,8 @@ public class LoaderCustomSupport extends FragmentActivity {
|
|||||||
mLoader.getContext().registerReceiver(this, filter);
|
mLoader.getContext().registerReceiver(this, filter);
|
||||||
// Register for events related to sdcard installation.
|
// Register for events related to sdcard installation.
|
||||||
IntentFilter sdFilter = new IntentFilter();
|
IntentFilter sdFilter = new IntentFilter();
|
||||||
sdFilter.addAction(Intent.ACTION_EXTERNAL_APPLICATIONS_AVAILABLE);
|
sdFilter.addAction(IntentCompat.ACTION_EXTERNAL_APPLICATIONS_AVAILABLE);
|
||||||
sdFilter.addAction(Intent.ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE);
|
sdFilter.addAction(IntentCompat.ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE);
|
||||||
mLoader.getContext().registerReceiver(this, sdFilter);
|
mLoader.getContext().registerReceiver(this, sdFilter);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -372,7 +375,9 @@ public class LoaderCustomSupport extends FragmentActivity {
|
|||||||
public void setData(List<AppEntry> data) {
|
public void setData(List<AppEntry> data) {
|
||||||
clear();
|
clear();
|
||||||
if (data != null) {
|
if (data != null) {
|
||||||
addAll(data);
|
for (AppEntry appEntry : data) {
|
||||||
|
add(appEntry);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -397,7 +402,7 @@ public class LoaderCustomSupport extends FragmentActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static class AppListFragment extends ListFragment
|
public static class AppListFragment extends ListFragment
|
||||||
implements OnQueryTextListener, LoaderManager.LoaderCallbacks<List<AppEntry>> {
|
implements LoaderManager.LoaderCallbacks<List<AppEntry>> {
|
||||||
|
|
||||||
// This is the Adapter being used to display the list's data.
|
// This is the Adapter being used to display the list's data.
|
||||||
AppListAdapter mAdapter;
|
AppListAdapter mAdapter;
|
||||||
@@ -405,6 +410,8 @@ public class LoaderCustomSupport extends FragmentActivity {
|
|||||||
// If non-null, this is the current filter the user has provided.
|
// If non-null, this is the current filter the user has provided.
|
||||||
String mCurFilter;
|
String mCurFilter;
|
||||||
|
|
||||||
|
OnQueryTextListenerCompat mOnQueryTextListenerCompat;
|
||||||
|
|
||||||
@Override public void onActivityCreated(Bundle savedInstanceState) {
|
@Override public void onActivityCreated(Bundle savedInstanceState) {
|
||||||
super.onActivityCreated(savedInstanceState);
|
super.onActivityCreated(savedInstanceState);
|
||||||
|
|
||||||
@@ -431,23 +438,22 @@ public class LoaderCustomSupport extends FragmentActivity {
|
|||||||
// Place an action bar item for searching.
|
// Place an action bar item for searching.
|
||||||
MenuItem item = menu.add("Search");
|
MenuItem item = menu.add("Search");
|
||||||
item.setIcon(android.R.drawable.ic_menu_search);
|
item.setIcon(android.R.drawable.ic_menu_search);
|
||||||
item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
|
MenuItemCompat.setShowAsAction(item, MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);
|
||||||
SearchView sv = new SearchView(getActivity());
|
View searchView = SearchViewCompat.newSearchView(getActivity());
|
||||||
sv.setOnQueryTextListener(this);
|
if (searchView != null) {
|
||||||
item.setActionView(sv);
|
SearchViewCompat.setOnQueryTextListener(searchView,
|
||||||
}
|
new OnQueryTextListenerCompat() {
|
||||||
|
@Override
|
||||||
@Override public boolean onQueryTextChange(String newText) {
|
public boolean onQueryTextChange(String newText) {
|
||||||
// Called when the action bar search text has changed. Since this
|
// Called when the action bar search text has changed. Since this
|
||||||
// is a simple array adapter, we can just have it do the filtering.
|
// is a simple array adapter, we can just have it do the filtering.
|
||||||
mCurFilter = !TextUtils.isEmpty(newText) ? newText : null;
|
mCurFilter = !TextUtils.isEmpty(newText) ? newText : null;
|
||||||
mAdapter.getFilter().filter(mCurFilter);
|
mAdapter.getFilter().filter(mCurFilter);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
});
|
||||||
@Override public boolean onQueryTextSubmit(String query) {
|
MenuItemCompat.setActionView(item, searchView);
|
||||||
// Don't care about this.
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void onListItemClick(ListView l, View v, int position, long id) {
|
@Override public void onListItemClick(ListView l, View v, int position, long id) {
|
||||||
|
|||||||
@@ -17,14 +17,6 @@
|
|||||||
package com.example.android.supportv4.app;
|
package com.example.android.supportv4.app;
|
||||||
|
|
||||||
//BEGIN_INCLUDE(complete)
|
//BEGIN_INCLUDE(complete)
|
||||||
import android.support.v4.app.FragmentActivity;
|
|
||||||
import android.support.v4.app.FragmentManager;
|
|
||||||
import android.support.v4.app.ListFragment;
|
|
||||||
import android.support.v4.app.LoaderManager;
|
|
||||||
import android.support.v4.content.CursorLoader;
|
|
||||||
import android.support.v4.content.Loader;
|
|
||||||
import android.support.v4.widget.SimpleCursorAdapter;
|
|
||||||
|
|
||||||
import android.content.ContentProvider;
|
import android.content.ContentProvider;
|
||||||
import android.content.ContentResolver;
|
import android.content.ContentResolver;
|
||||||
import android.content.ContentUris;
|
import android.content.ContentUris;
|
||||||
@@ -32,7 +24,6 @@ import android.content.ContentValues;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.UriMatcher;
|
import android.content.UriMatcher;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.database.DatabaseUtils;
|
|
||||||
import android.database.SQLException;
|
import android.database.SQLException;
|
||||||
import android.database.sqlite.SQLiteDatabase;
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
import android.database.sqlite.SQLiteOpenHelper;
|
import android.database.sqlite.SQLiteOpenHelper;
|
||||||
@@ -41,6 +32,15 @@ import android.net.Uri;
|
|||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.provider.BaseColumns;
|
import android.provider.BaseColumns;
|
||||||
|
import android.support.v4.app.FragmentActivity;
|
||||||
|
import android.support.v4.app.FragmentManager;
|
||||||
|
import android.support.v4.app.ListFragment;
|
||||||
|
import android.support.v4.app.LoaderManager;
|
||||||
|
import android.support.v4.content.CursorLoader;
|
||||||
|
import android.support.v4.content.Loader;
|
||||||
|
import android.support.v4.database.DatabaseUtilsCompat;
|
||||||
|
import android.support.v4.view.MenuItemCompat;
|
||||||
|
import android.support.v4.widget.SimpleCursorAdapter;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
@@ -226,7 +226,7 @@ public class LoaderThrottleSupport extends FragmentActivity {
|
|||||||
// The incoming URI is for a single row.
|
// The incoming URI is for a single row.
|
||||||
qb.setProjectionMap(mNotesProjectionMap);
|
qb.setProjectionMap(mNotesProjectionMap);
|
||||||
qb.appendWhere(MainTable._ID + "=?");
|
qb.appendWhere(MainTable._ID + "=?");
|
||||||
selectionArgs = DatabaseUtils.appendSelectionArgs(selectionArgs,
|
selectionArgs = DatabaseUtilsCompat.appendSelectionArgs(selectionArgs,
|
||||||
new String[] { uri.getLastPathSegment() });
|
new String[] { uri.getLastPathSegment() });
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -321,7 +321,7 @@ public class LoaderThrottleSupport extends FragmentActivity {
|
|||||||
case MAIN_ID:
|
case MAIN_ID:
|
||||||
// If URI is for a particular row ID, delete is based on incoming
|
// If URI is for a particular row ID, delete is based on incoming
|
||||||
// data but modified to restrict to the given ID.
|
// data but modified to restrict to the given ID.
|
||||||
finalWhere = DatabaseUtils.concatenateWhere(
|
finalWhere = DatabaseUtilsCompat.concatenateWhere(
|
||||||
MainTable._ID + " = " + ContentUris.parseId(uri), where);
|
MainTable._ID + " = " + ContentUris.parseId(uri), where);
|
||||||
count = db.delete(MainTable.TABLE_NAME, finalWhere, whereArgs);
|
count = db.delete(MainTable.TABLE_NAME, finalWhere, whereArgs);
|
||||||
break;
|
break;
|
||||||
@@ -353,7 +353,7 @@ public class LoaderThrottleSupport extends FragmentActivity {
|
|||||||
case MAIN_ID:
|
case MAIN_ID:
|
||||||
// If URI is for a particular row ID, update is based on incoming
|
// If URI is for a particular row ID, update is based on incoming
|
||||||
// data but modified to restrict to the given ID.
|
// data but modified to restrict to the given ID.
|
||||||
finalWhere = DatabaseUtils.concatenateWhere(
|
finalWhere = DatabaseUtilsCompat.concatenateWhere(
|
||||||
MainTable._ID + " = " + ContentUris.parseId(uri), where);
|
MainTable._ID + " = " + ContentUris.parseId(uri), where);
|
||||||
count = db.update(MainTable.TABLE_NAME, values, finalWhere, whereArgs);
|
count = db.update(MainTable.TABLE_NAME, values, finalWhere, whereArgs);
|
||||||
break;
|
break;
|
||||||
@@ -419,10 +419,10 @@ public class LoaderThrottleSupport extends FragmentActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||||
menu.add(Menu.NONE, POPULATE_ID, 0, "Populate")
|
MenuItem populateItem = menu.add(Menu.NONE, POPULATE_ID, 0, "Populate");
|
||||||
.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
|
MenuItemCompat.setShowAsAction(populateItem, MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);
|
||||||
menu.add(Menu.NONE, CLEAR_ID, 0, "Clear")
|
MenuItem clearItem = menu.add(Menu.NONE, CLEAR_ID, 0, "Clear");
|
||||||
.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
|
MenuItemCompat.setShowAsAction(clearItem, MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public boolean onOptionsItemSelected(MenuItem item) {
|
@Override public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
@@ -453,8 +453,7 @@ public class LoaderThrottleSupport extends FragmentActivity {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
mPopulatingTask.executeOnExecutor(
|
mPopulatingTask.execute((Void[]) null);
|
||||||
AsyncTask.THREAD_POOL_EXECUTOR, (Void[])null);
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case CLEAR_ID:
|
case CLEAR_ID:
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import android.os.Bundle;
|
|||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
|
import android.support.v4.app.ServiceCompat;
|
||||||
import android.support.v4.content.LocalBroadcastManager;
|
import android.support.v4.content.LocalBroadcastManager;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
@@ -135,7 +136,6 @@ public class LocalServiceBroadcaster extends Activity {
|
|||||||
mLocalBroadcastManager = LocalBroadcastManager.getInstance(this);
|
mLocalBroadcastManager = LocalBroadcastManager.getInstance(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||||
// Tell any local interested parties about the start.
|
// Tell any local interested parties about the start.
|
||||||
mLocalBroadcastManager.sendBroadcast(new Intent(ACTION_STARTED));
|
mLocalBroadcastManager.sendBroadcast(new Intent(ACTION_STARTED));
|
||||||
@@ -144,7 +144,7 @@ public class LocalServiceBroadcaster extends Activity {
|
|||||||
mHandler.removeMessages(MSG_UPDATE);
|
mHandler.removeMessages(MSG_UPDATE);
|
||||||
Message msg = mHandler.obtainMessage(MSG_UPDATE);
|
Message msg = mHandler.obtainMessage(MSG_UPDATE);
|
||||||
mHandler.sendMessageDelayed(msg, 1000);
|
mHandler.sendMessageDelayed(msg, 1000);
|
||||||
return Service.START_STICKY;
|
return ServiceCompat.START_STICKY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user