22
33import android .content .Intent ;
44import android .os .Bundle ;
5- import android .os . Handler ;
5+ import android .text . TextUtils ;
66import android .view .View ;
77import android .widget .AdapterView ;
88import android .widget .ListAdapter ;
@@ -57,13 +57,14 @@ public void onClick(View view) {
5757 @ Override
5858 protected void onStart () {
5959 super .onStart ();
60- initBranchSession ( );
60+ AdobeBranch . initSession ( branchInitSessionCallback , getIntent (). getData (), this );
6161 }
6262
6363 @ Override
6464 public void onNewIntent (Intent intent ) {
6565 super .onNewIntent (intent );
6666 this .setIntent (intent );
67+ AdobeBranch .initSession (branchInitSessionCallback , getIntent ().getData (), this , 0 );
6768 }
6869
6970 private void initList () {
@@ -88,16 +89,16 @@ public void onItemClick(AdapterView<?> parent, View view, int position, long id)
8889 }
8990 }
9091
91- private void initBranchSession () {
92- AdobeBranch .initSession (new Branch .BranchReferralInitListener () {
92+ private Branch .BranchReferralInitListener branchInitSessionCallback = new Branch .BranchReferralInitListener () {
9393 @ Override
9494 public void onInitFinished (JSONObject referringParams , BranchError error ) {
95+ PrefHelper .Debug ("initBranchSession, referringParams = " + referringParams + ", error = " + error );
9596 if (referringParams == null ) return ;
9697 try {
9798 // You would think that there was an easier way to figure this out than looking at LinkProperties code
9899 if (referringParams .has ("+clicked_branch_link" ) && referringParams .getBoolean ("+clicked_branch_link" )) {
99100 String idString = referringParams .optString (SwagActivity .SWAG_ID );
100- if (idString != null ) {
101+ if (! TextUtils . isEmpty ( idString ) ) {
101102 int swagId = Integer .parseInt (idString );
102103
103104 // Launch the Swag Activity
@@ -111,8 +112,8 @@ public void onInitFinished(JSONObject referringParams, BranchError error) {
111112 // internal error; id is not a number.
112113 }
113114 }
114- }, getIntent (). getData (), this ) ;
115- }
115+ };
116+
116117
117118 private void shareProduct () {
118119 BranchUniversalObject buo = new BranchUniversalObject ();
0 commit comments