Skip to content

Commit

Permalink
Fix delete account dialog only deletes splits and not whole transaction
Browse files Browse the repository at this point in the history
Fix display of transaction time in list (show full dates for times greater or less than a few days)
Remove prettytime dependency
  • Loading branch information
codinguser committed Nov 4, 2015
1 parent c7e7a80 commit 22b5327
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
1 change: 0 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@ dependencies {
'org.jraf:android-switch-backport:2.0.1@aar',
'com.github.PhilJay:MPAndroidChart:v2.1.3',
'joda-time:joda-time:2.7',
'org.ocpsoft.prettytime:prettytime:3.2.7.Final',
'com.google.android.gms:play-services-drive:7.0.0',
'com.jakewharton:butterknife:7.0.1',
'com.kobakei:ratethisapp:0.0.3',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,13 +228,7 @@ public void onClick(View v) {
}

if (GnuCashApplication.isDoubleEntryEnabled()){ //reassign splits to imbalance
Currency accountCurrency = Currency.getInstance(accountsDbAdapter.getCurrencyCode(mOriginAccountUID));
String imbalanceAccountUID = accountsDbAdapter.getOrCreateImbalanceAccountUID(accountCurrency);
SplitsDbAdapter.getInstance().updateRecords(
DatabaseSchema.SplitEntry.COLUMN_ACCOUNT_UID + "=?",
new String[]{mOriginAccountUID},
DatabaseSchema.SplitEntry.COLUMN_ACCOUNT_UID,
imbalanceAccountUID);
TransactionsDbAdapter.getInstance().deleteTransactionsForAccount(mOriginAccountUID);
}

//now kill them all!!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.PopupMenu;
import android.support.v7.widget.RecyclerView;
import android.text.format.DateUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
Expand All @@ -56,8 +57,8 @@
import org.gnucash.android.ui.util.CursorRecyclerAdapter;
import org.gnucash.android.ui.util.Refreshable;
import org.gnucash.android.ui.util.widget.EmptyRecyclerView;
import org.ocpsoft.prettytime.PrettyTime;

import java.text.DateFormat;
import java.util.Date;
import java.util.List;

Expand Down Expand Up @@ -220,7 +221,8 @@ public Cursor loadInBackground() {

public class TransactionRecyclerAdapter extends CursorRecyclerAdapter<TransactionRecyclerAdapter.ViewHolder>{

private final PrettyTime prettyTime = new PrettyTime();
DateFormat simpleDateFormat = DateFormat.getDateInstance(DateFormat.MEDIUM);

public TransactionRecyclerAdapter(Cursor cursor) {
super(cursor);
}
Expand Down Expand Up @@ -262,7 +264,13 @@ public void onBindViewHolderCursor(ViewHolder holder, Cursor cursor) {
holder.transactionNote.setText(text);

long dateMillis = cursor.getLong(cursor.getColumnIndexOrThrow(DatabaseSchema.TransactionEntry.COLUMN_TIMESTAMP));
holder.transactionDate.setText(prettyTime.format(new Date(dateMillis)));
String dateText;
if (dateMillis > System.currentTimeMillis()){
dateText = simpleDateFormat.format(new Date(dateMillis));
} else {
dateText = DateUtils.getRelativeTimeSpanString(dateMillis).toString();
}
holder.transactionDate.setText(dateText);

final long id = holder.transactionId;
holder.itemView.setOnClickListener(new View.OnClickListener() {
Expand Down

0 comments on commit 22b5327

Please sign in to comment.