Skip to content

Commit

Permalink
Preparing release 2.1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
queue-it committed Aug 11, 2022
1 parent 1c10e46 commit b84df99
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 127 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,4 @@ If your application is using an API that's protected by a Queue-it connector (Kn

```xml
<activity android:name="com.queue_it.androidsdk.QueueActivity" />
```
```
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ allprojects {
groupId = 'com.queue-it.androidsdk'
libraryName = 'com.queue_it.androidsdk'
libraryDescription = 'Android SDK to integrate with Queue-it'
libraryVersion = "2.1.3"
libraryVersion = "2.1.4"
organization = "Queue-it"
organizationUrl = "https://queue-it.com"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import com.queue_it.androidsdk.Error;

public class MainActivity extends AppCompatActivity {
RadioButton enableCacheRadioButton;
FloatingActionButton queue_button;
EditText customerIdEditText;
EditText eventIdEditText;
Expand All @@ -34,11 +33,11 @@ private void runQueue(QueueITEngine queueITEngine) throws QueueITException {
String enqueueToken = enqueueTokenEditText.getText().toString();
String enqueueKey = enqueueKeyEditText.getText().toString();
if (enqueueToken.length() > 0) {
queueITEngine.runWithEnqueueToken(MainActivity.this, enqueueToken, !enableCacheRadioButton.isChecked());
queueITEngine.runWithEnqueueToken(MainActivity.this, enqueueToken);
} else if (enqueueKey.length() > 0) {
queueITEngine.runWithEnqueueKey(MainActivity.this, enqueueKey, !enableCacheRadioButton.isChecked());
queueITEngine.runWithEnqueueKey(MainActivity.this, enqueueKey);
} else {
queueITEngine.run(MainActivity.this, !enableCacheRadioButton.isChecked());
queueITEngine.run(MainActivity.this);
}
}

Expand All @@ -53,7 +52,6 @@ protected void onCreate(Bundle savedInstanceState) {
layoutNameEditText = findViewById(R.id.layoutname_edittext);
languageEditText = findViewById(R.id.language_edittext);
testRadioButton = findViewById(R.id.radio_environment_test);
enableCacheRadioButton = findViewById(R.id.radio_cache_enabled);
customerIdEditText.addTextChangedListener(getRequiredTextValidator(customerIdEditText));
eventIdEditText.addTextChangedListener(getRequiredTextValidator(eventIdEditText));
enqueueTokenEditText = findViewById(R.id.enqueuetoken_edittext);
Expand Down
29 changes: 0 additions & 29 deletions demoapp/src/library/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -145,36 +145,7 @@
</RadioGroup>

</TableRow>
<TableRow>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right"
android:padding="10dip"
android:text="Cache:" />

<RadioGroup
android:orientation="horizontal"
android:checkedButton="@+id/radio_cache_enabled"
>
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Enabled"
android:id="@+id/radio_cache_enabled"
android:layout_column="1" />

<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Disabled"
android:id="@+id/radio_cache_disabled"
android:layout_column="1" />

</RadioGroup>

</TableRow>
</TableLayout>

<com.google.android.material.floatingactionbutton.FloatingActionButton
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import com.queue_it.androidsdk.Error;

public class MainActivity extends AppCompatActivity {
RadioButton enableCacheRadioButton;
FloatingActionButton queue_button;
FloatingActionButton queueSession_button;
FloatingActionButton show_queue_button;
Expand Down Expand Up @@ -95,11 +94,11 @@ private void runQueue(QueueITEngine queueITEngine) throws QueueITException {
String enqueueToken = enqueueTokenEditText.getText().toString();
String enqueueKey = enqueueKeyEditText.getText().toString();
if (enqueueToken.length() > 0) {
queueITEngine.runWithEnqueueToken(this, enqueueToken, !enableCacheRadioButton.isChecked());
queueITEngine.runWithEnqueueToken(this, enqueueToken);
} else if (enqueueKey.length() > 0) {
queueITEngine.runWithEnqueueKey(this, enqueueKey, !enableCacheRadioButton.isChecked());
queueITEngine.runWithEnqueueKey(this, enqueueKey);
} else {
queueITEngine.run(this, !enableCacheRadioButton.isChecked());
queueITEngine.run(this);
}
}

Expand Down Expand Up @@ -128,7 +127,6 @@ protected void onCreate(Bundle savedInstanceState) {
layoutNameEditText = findViewById(R.id.layoutname_edittext);
languageEditText = findViewById(R.id.language_edittext);
testRadioButton = findViewById(R.id.radio_environment_test);
enableCacheRadioButton = findViewById(R.id.radio_cache_enabled);
customerIdEditText.addTextChangedListener(getRequiredTextValidator(customerIdEditText));
eventIdEditText.addTextChangedListener(getRequiredTextValidator(eventIdEditText));
enqueueTokenEditText = findViewById(R.id.enqueuetoken_edittext);
Expand Down
30 changes: 0 additions & 30 deletions demoapp/src/library_androidx/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -145,36 +145,6 @@
</RadioGroup>

</TableRow>
<TableRow>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right"
android:padding="10dip"
android:text="Cache:" />

<RadioGroup
android:orientation="horizontal"
android:checkedButton="@+id/radio_cache_enabled"
>
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Enabled"
android:id="@+id/radio_cache_enabled"
android:layout_column="1" />

<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Disabled"
android:id="@+id/radio_cache_disabled"
android:layout_column="1" />

</RadioGroup>

</TableRow>
</TableLayout>

<TableLayout
Expand Down
61 changes: 5 additions & 56 deletions library/src/main/java/com/queue_it/androidsdk/QueueITEngine.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ public class QueueITEngine {
private QueueITWaitingRoomProvider _queueITWaitingRoomProvider;
private QueueITWaitingRoomView _queueITWaitingRoomView;

private final QueueCache _queueCache;

private QueueListener _queueITEngineListener;
private QueueTryPassResult _queueTryPassResult;

Expand Down Expand Up @@ -53,13 +51,11 @@ public QueueITEngine(Context activityContext,
options = QueueItEngineOptions.getDefault();
}
UserAgentManager.initialize(activityContext);
_queueCache = new QueueCache(activityContext, customerId, eventOrAliasId);
_queueITEngineListener = queueListener;

QueueListener queueITQueueListener = new QueueListener() {
@Override
protected void onQueuePassed(QueuePassedInfo queuePassedInfo) {
_queueCache.clear();
_queueITEngineListener.onQueuePassed(queuePassedInfo);
}

Expand All @@ -85,7 +81,6 @@ protected void onError(Error error, String errorMessage) {

@Override
public void onSessionRestart(QueueITEngine queueITEngine) {
_queueCache.clear();
_queueITEngineListener.onSessionRestart(QueueITEngine.this);
}

Expand All @@ -102,7 +97,6 @@ public void onWebViewClosed() {
@Override
protected void onQueueUrlChanged(String url) {
_queueITEngineListener.onQueueUrlChanged(url);
updateQueuePageUrl(url);
}
};

Expand All @@ -120,7 +114,6 @@ public void onSuccess(QueueTryPassResult queueTryPassResult) {

_queueTryPassResult = queueTryPassResult;
_queueITWaitingRoomView.showQueue(_queueTryPassResult);
_queueCache.update(queueTryPassResult.getQueueUrl(), queueTryPassResult.getUrlTTLInMinutes(), queueTryPassResult.getTargetUrl());
}

@Override
Expand All @@ -145,76 +138,32 @@ public boolean IsRequestInProgress() {
return _queueITWaitingRoomProvider.IsRequestInProgress();
}

public void run(Context activityContext, boolean clearCache) throws QueueITException {
if (clearCache) {
_queueCache.clear();
}
run(activityContext);
}


public void run(Context activityContext) throws QueueITException {
if(!tryToShowQueueFromCache()){
_queueITWaitingRoomProvider.tryPass();
}
}

public void runWithEnqueueToken(Context activityContext, String enqueueToken) throws QueueITException {
runWithEnqueueToken(activityContext, enqueueToken, false);
}

public void runWithEnqueueToken(Context activityContext, String enqueueToken, boolean clearCache)

public void runWithEnqueueToken(Context activityContext, String enqueueToken)
throws QueueITException {
if (_queueITWaitingRoomProvider.IsRequestInProgress()){
throw new QueueITException("Request is already in progress");
}
if (clearCache) {
_queueCache.clear();
}

if(!tryToShowQueueFromCache()){
_queueITWaitingRoomProvider.tryPassWithEnqueueToken(enqueueToken);
}

}

public void runWithEnqueueKey(Context activityContext, String enqueueKey) throws QueueITException {
runWithEnqueueKey(activityContext, enqueueKey, false);
}

public void runWithEnqueueKey(Context activityContext, String enqueueKey, boolean clearCache)
public void runWithEnqueueKey(Context activityContext, String enqueueKey)
throws QueueITException {
if (_queueITWaitingRoomProvider.IsRequestInProgress()){
throw new QueueITException("Request is already in progress");
}
if (clearCache) {
_queueCache.clear();
}
if(!tryToShowQueueFromCache()){
_queueITWaitingRoomProvider.tryPassWithEnqueueKey(enqueueKey);
}
}

private boolean tryToShowQueueFromCache() {
if (_queueCache.isEmpty()) {
return false;
}

Calendar cachedTime = _queueCache.getUrlTtl();
Calendar currentTime = Calendar.getInstance();

if (currentTime.compareTo(cachedTime) < 0) {
String queueUrl = _queueCache.getQueueUrl();
Log.v("QueueITEngine", String.format("Using queueUrl from cache: %s", queueUrl));
_queueITWaitingRoomView.showQueue(_queueTryPassResult);
return true;
}
return false;
}

private void updateQueuePageUrl(String queueUrl) {
if (!_queueCache.isEmpty()) {
_queueCache.update(queueUrl, _queueCache.getUrlTtl(), _queueCache.getTargetUrl());
}
_queueITWaitingRoomProvider.tryPassWithEnqueueKey(enqueueKey);
}

public String getSdkVersion() {
Expand Down

0 comments on commit b84df99

Please sign in to comment.