Skip to content

Commit 30e6374

Browse files
authored
Merge pull request #30 from evotor/develop
Открытие чека возврата
2 parents 6f57050 + 9a9b517 commit 30e6374

File tree

4 files changed

+93
-12
lines changed

4 files changed

+93
-12
lines changed
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
package ru.evotor.framework.core.action.command.open_receipt_command;
2+
3+
import android.content.ComponentName;
4+
import android.content.Context;
5+
import android.os.Bundle;
6+
import android.os.Handler;
7+
import android.os.Looper;
8+
import android.os.Parcelable;
9+
10+
import java.util.ArrayList;
11+
import java.util.List;
12+
import java.util.Objects;
13+
14+
import ru.evotor.framework.Utils;
15+
import ru.evotor.framework.core.ICanStartActivity;
16+
import ru.evotor.framework.core.IntegrationManagerCallback;
17+
import ru.evotor.framework.core.IntegrationManagerImpl;
18+
import ru.evotor.framework.core.action.datamapper.ChangesMapper;
19+
import ru.evotor.framework.core.action.event.receipt.changes.IChange;
20+
import ru.evotor.framework.core.action.event.receipt.changes.position.PositionAdd;
21+
22+
/**
23+
* Created by a.kuznetsov on 26/04/2017.
24+
*/
25+
26+
public class OpenPaybackReceiptCommand {
27+
28+
public static final String NAME = "evo.v2.receipt.payback.openReceipt";
29+
private static final String KEY_CHANGES = "changes";
30+
31+
public static OpenPaybackReceiptCommand create(Bundle bundle) {
32+
Parcelable[] changesParcelable = bundle.getParcelableArray(KEY_CHANGES);
33+
return new OpenPaybackReceiptCommand(Utils.filterByClass(
34+
ChangesMapper.INSTANCE.create(changesParcelable),
35+
PositionAdd.class
36+
));
37+
}
38+
39+
private final List<PositionAdd> changes;
40+
41+
public OpenPaybackReceiptCommand(List<PositionAdd> changes) {
42+
this.changes = new ArrayList<>();
43+
if (changes != null) {
44+
this.changes.addAll(changes);
45+
}
46+
}
47+
48+
public void process(final Context context, final ICanStartActivity activityStarter, IntegrationManagerCallback callback) {
49+
Objects.requireNonNull(activityStarter);
50+
Objects.requireNonNull(context);
51+
52+
List<ComponentName> componentNameList = IntegrationManagerImpl.convertImplicitIntentToExplicitIntent(NAME, context.getApplicationContext());
53+
if (componentNameList == null || componentNameList.isEmpty()) {
54+
return;
55+
}
56+
new IntegrationManagerImpl(context.getApplicationContext())
57+
.call(OpenPaybackReceiptCommand.NAME,
58+
59+
componentNameList.get(0),
60+
this.toBundle(),
61+
activityStarter,
62+
callback,
63+
new Handler(Looper.getMainLooper())
64+
);
65+
}
66+
67+
public Bundle toBundle() {
68+
Bundle bundle = new Bundle();
69+
Parcelable[] changesParcelable = new Parcelable[changes.size()];
70+
for (int i = 0; i < changesParcelable.length; i++) {
71+
IChange change = changes.get(i);
72+
changesParcelable[i] = ChangesMapper.INSTANCE.toBundle(change);
73+
}
74+
bundle.putParcelableArray(KEY_CHANGES, changesParcelable);
75+
return bundle;
76+
}
77+
78+
public List<PositionAdd> getChanges() {
79+
return changes;
80+
}
81+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package ru.evotor.framework.core.action.event.receipt;
2+
3+
/**
4+
* Created by a.kuznetsov on 18/05/2017.
5+
*/
6+
7+
public interface ReceiptOpenedEvent {
8+
String BROADCAST_ACTION_SELL_RECEIPT = "evotor.intent.action.receipt.sell.OPENED";
9+
String BROADCAST_ACTION_PAYBACK_RECEIPT = "evotor.intent.action.receipt.payback.OPENED";
10+
String KEY_UUID = "uuid";
11+
}

app/src/main/java/ru/evotor/framework/core/action/event/receipt/SellReceiptOpenedEvent.java

Lines changed: 0 additions & 10 deletions
This file was deleted.

app/src/main/java/ru/evotor/framework/core/action/event/receipt/position_edited/PositionEditedEvent.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@
99
*/
1010

1111
public class PositionEditedEvent extends PositionEvent {
12-
public static final String BROADCAST_ACTION = "evotor.intent.action.receipt.sell.POSITION_EDITED";
1312
public static final String BROADCAST_ACTION_SELL_RECEIPT = "evotor.intent.action.receipt.sell.POSITION_EDITED";
14-
public static final String BROADCAST_ACTION_PAYBACK_RECEIPT = "evotor.intent.action.receipt.payback.POSITION_ADDED";
13+
public static final String BROADCAST_ACTION_PAYBACK_RECEIPT = "evotor.intent.action.receipt.payback.POSITION_EDITED";
1514

1615
public PositionEditedEvent(Bundle extras) {
1716
super(extras);

0 commit comments

Comments
 (0)