Skip to content

Commit

Permalink
Merge pull request #95 from plaid/ANDROID/updateTo3.0.0
Browse files Browse the repository at this point in the history
ANDROID-529: Upgrade from 2.x to 3.0.0
  • Loading branch information
amytang0 authored Sep 23, 2020
2 parents 0b17cc8 + ec273fc commit e54cd6f
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 29 deletions.
11 changes: 6 additions & 5 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@ android {
}

dependencies {
implementation "com.plaid.link:sdk-core:2.2.0"
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation "com.plaid.link:sdk-core:3.0.0"

implementation "androidx.appcompat:appcompat:1.2.0"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation 'androidx.core:core-ktx:1.3.1'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.material:material:1.2.0'
implementation "androidx.core:core-ktx:1.3.1"
implementation "androidx.constraintlayout:constraintlayout:1.1.3"
implementation "com.google.android.material:material:1.2.0"

implementation "com.squareup.retrofit2:retrofit:2.9.0"
implementation "com.squareup.retrofit2:converter-gson:2.9.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,5 @@ class LinkSampleApplication : Application() {
override fun onCreate() {
super.onCreate()

Plaid.initialize(this)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,5 @@ public class LinkSampleApplicationJava extends Application {
public void onCreate() {
super.onCreate();

Plaid.initialize(this);
}
}
17 changes: 9 additions & 8 deletions app/src/main/java/com/plaid/linksample/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ import android.widget.TextView
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import com.plaid.link.Plaid
import com.plaid.link.linkTokenConfiguration
import com.plaid.link.openPlaidLink
import com.plaid.link.result.PlaidLinkResultHandler
import com.plaid.link.configuration.LinkTokenConfiguration
import com.plaid.link.result.LinkResultHandler
import com.plaid.linksample.network.LinkTokenRequester

class MainActivity : AppCompatActivity() {
Expand All @@ -25,7 +24,7 @@ class MainActivity : AppCompatActivity() {
private lateinit var tokenResult: TextView

private val myPlaidResultHandler by lazy {
PlaidLinkResultHandler(
LinkResultHandler(
onSuccess = {
tokenResult.text = getString(R.string.public_token_result, it.publicToken)
result.text = getString(R.string.content_success)
Expand Down Expand Up @@ -77,11 +76,13 @@ class MainActivity : AppCompatActivity() {
}

private fun onLinkTokenSuccess(linkToken: String) {
this@MainActivity.openPlaidLink(
linkTokenConfiguration = linkTokenConfiguration {
token = linkToken
}
Plaid.create(
this.application,
LinkTokenConfiguration.Builder()
.token(linkToken)
.build()
)
.open(this)
}

private fun onLinkTokenError(error: Throwable) {
Expand Down
29 changes: 15 additions & 14 deletions app/src/main/java/com/plaid/linksample/MainActivityJava.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,21 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import com.plaid.link.Plaid;
import com.plaid.link.configuration.LinkTokenConfiguration;
import com.plaid.link.configuration.PlaidProduct;
import com.plaid.link.result.PlaidLinkResultHandler;
import com.plaid.link.result.LinkResultHandler;
import com.plaid.linksample.network.LinkTokenRequester;
import java.util.ArrayList;

import kotlin.Unit;


public class MainActivityJava extends AppCompatActivity {

private TextView result;
private TextView tokenResult;

private final PlaidLinkResultHandler myPlaidResultHandler = new PlaidLinkResultHandler(
private LinkResultHandler myPlaidResultHandler = new LinkResultHandler(
linkSuccess -> {
tokenResult.setText(getString(
R.string.public_token_result,
Expand All @@ -40,15 +41,17 @@ public class MainActivityJava extends AppCompatActivity {
},
linkExit -> {
tokenResult.setText("");
if (linkExit.error != null) {
if (linkExit.getError() != null) {
result.setText(getString(
R.string.content_exit,
linkExit.error.getDisplayMessage(),
linkExit.error.getErrorCode()));
linkExit.getError().getDisplayMessage(),
linkExit.getError().getErrorCode()));
} else {
result.setText(getString(
R.string.content_cancel,
linkExit.metadata.status != null ? linkExit.metadata.status.jsonValue : "unknown"));
linkExit.getMetadata().getStatus() != null ? linkExit.getMetadata()
.getStatus()
.getJsonValue() : "unknown"));
}
return Unit.INSTANCE;
}
Expand Down Expand Up @@ -83,19 +86,17 @@ private void setOptionalEventListener() {
* <a href="https://plaid.com/docs/link/android/#parameter-reference">parameter reference</>
*/
private void openLink() {
ArrayList<PlaidProduct> products = new ArrayList<>();
products.add(PlaidProduct.TRANSACTIONS);
LinkTokenRequester.INSTANCE.getToken()
.subscribe(this::onLinkTokenSuccess, this::onLinkTokenError);
}

private void onLinkTokenSuccess(String token) {
Plaid.openLink(
this,
Plaid.create(
getApplication(),
new LinkTokenConfiguration.Builder()
.token(token)
.build()
.toLinkConfiguration());
.build())
.open(this);
}

private void onLinkTokenError(Throwable error) {
Expand Down

0 comments on commit e54cd6f

Please sign in to comment.