Skip to content

Commit

Permalink
use method from sherlock
Browse files Browse the repository at this point in the history
  • Loading branch information
mtotschnig committed Jul 4, 2013
1 parent 1c1622f commit b37e33d
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/org/totschnig/myexpenses/fragment/TransactionList.java
Expand Up @@ -13,6 +13,7 @@
import org.totschnig.myexpenses.util.Utils;

import com.actionbarsherlock.app.SherlockFragment;
import com.actionbarsherlock.app.SherlockFragmentActivity;

import android.content.ContentResolver;
import android.content.Intent;
Expand Down Expand Up @@ -64,7 +65,7 @@ public void onCreate(Bundle savedInstanceState) {
mAccount = Account.getInstanceFromDb(getArguments().getLong("account_id"));
tObserver = new TransactionsObserver(new Handler());
aObserver = new AccountObserver(new Handler());
ContentResolver cr= getActivity().getContentResolver();
ContentResolver cr= getSherlockActivity().getContentResolver();
//we adjust the balance, when transactions have been added/deleted/updated
cr.registerContentObserver(TransactionProvider.TRANSACTIONS_URI, true,tObserver);
//when account has changed, we might have
Expand All @@ -79,7 +80,7 @@ public void onCreate(Bundle savedInstanceState) {
public void onDestroy() {
super.onDestroy();
try {
ContentResolver cr = getActivity().getContentResolver();
ContentResolver cr = getSherlockActivity().getContentResolver();
cr.unregisterContentObserver(tObserver);
cr.unregisterContentObserver(aObserver);
} catch (IllegalStateException ise) {
Expand All @@ -89,7 +90,8 @@ public void onDestroy() {

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
Resources.Theme theme = getActivity().getTheme();
final SherlockFragmentActivity ctx = getSherlockActivity();
Resources.Theme theme = ctx.getTheme();
TypedValue color = new TypedValue();
theme.resolveAttribute(R.attr.colorExpense, color, true);
colorExpense = color.data;
Expand All @@ -99,7 +101,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
View v = inflater.inflate(R.layout.expenses_list, null, false);
//work around the problem that the view pager does not display its background correclty with Sherlock
if (Build.VERSION.SDK_INT < 11) {
v.setBackgroundColor(getActivity().getResources().getColor(
v.setBackgroundColor(ctx.getResources().getColor(
MyApplication.getThemeId() == R.style.ThemeLight ? android.R.color.white : android.R.color.black));
}
balanceTv = (TextView) v.findViewById(R.id.end);
Expand Down Expand Up @@ -127,7 +129,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
}
getLoaderManager().initLoader(0, null, this);
// Now create a simple cursor adapter and set it to display
mAdapter = new SimpleCursorAdapter(getActivity(), R.layout.expense_row, null, from, to,0) {
mAdapter = new SimpleCursorAdapter(ctx, R.layout.expense_row, null, from, to,0) {
/* (non-Javadoc)
* calls {@link #convText for formatting the values retrieved from the cursor}
* @see android.widget.SimpleCursorAdapter#setViewText(android.widget.TextView, java.lang.String)
Expand Down Expand Up @@ -191,7 +193,7 @@ public View getView(int position, View convertView, ViewGroup parent) {
@Override
public void onItemClick(AdapterView<?> a, View v,int position, long id)
{
Intent i = new Intent(getActivity(), ExpenseEdit.class);
Intent i = new Intent(ctx, ExpenseEdit.class);
i.putExtra(KEY_ROWID, id);
//i.putExtra("operationType", operationType);
startActivityForResult(i, MyExpenses.ACTIVITY_EDIT);
Expand All @@ -204,7 +206,7 @@ public void onItemClick(AdapterView<?> a, View v,int position, long id)

@Override
public Loader<Cursor> onCreateLoader(int arg0, Bundle arg1) {
CursorLoader cursorLoader = new CursorLoader(getActivity(),
CursorLoader cursorLoader = new CursorLoader(getSherlockActivity(),
TransactionProvider.TRANSACTIONS_URI, null, "account_id = ?", new String[] { String.valueOf(accountId) }, null);
return cursorLoader;
}
Expand Down

0 comments on commit b37e33d

Please sign in to comment.