Skip to content

Commit

Permalink
Offer handling in deeplink
Browse files Browse the repository at this point in the history
  • Loading branch information
banditAmit committed Jul 28, 2024
1 parent 913778d commit ae3f1ca
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 21 deletions.
50 changes: 30 additions & 20 deletions app/src/main/java/com/BugBazaar/ui/Deeplink.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,22 @@
public class Deeplink extends AppCompatActivity {
//private List<Product> products;
WebView webView;
TextView messageTextView;
TextView toolbarTitle;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_deep_link);

// Toolbar title set
TextView toolbarTitle = findViewById(R.id.toolbarTitle);
toolbarTitle.setText("DeepLink");

messageTextView= findViewById(R.id.messageTextView);
Intent intent = getIntent();
Uri deeplink = intent.getData();
toolbarTitle = findViewById(R.id.toolbarTitle);

// Deep link handling for item
if (deeplink != null && "/cart/add".equals(deeplink.getPath())) {
Expand All @@ -41,44 +50,45 @@ public void onCreate(Bundle savedInstanceState) {

// Deep link handling for msg
if (deeplink != null && "/offers".equals(deeplink.getPath())) {
String message = deeplink.getQueryParameter("msg");
if (message != null) {
// Display the message, e.g., in a TextView
TextView toolbarTitle = findViewById(R.id.toolbarTitle);
toolbarTitle.setText("Offers");
TextView messageTextView = findViewById(R.id.messageTextView);
String message = deeplink.getQueryParameter("textMsg");
String offer = deeplink.getQueryParameter("offer");
if (message != null && offer!=null) {
messageTextView.setText(message);
} else {
TextView toolbarTitle = findViewById(R.id.toolbarTitle);
toolbarTitle.setText("Offers");
TextView messageTextView = findViewById(R.id.messageTextView);
messageTextView.setText("Coming Soon...............!");
Intent intentA = new Intent(this, NavigationDrawer_Dashboard.class);
intentA.setData(Uri.parse(offer));
startActivity(intentA);
}


}

// Deep link handling for url
if (deeplink != null && "/web".equals(deeplink.getPath())) {
String webViewUrl = deeplink.getQueryParameter("url");
String webViewUrl = deeplink.getQueryParameter("urlToLoad");
// Check if the "url" parameter contains "payatu.com"
if (webViewUrl != null && webViewUrl.contains("payatu.com")) {
TextView toolbarTitle = findViewById(R.id.toolbarTitle);
toolbarTitle.setText("BugBazaar");

webView = findViewById(R.id.deeplink_view);
setupwebview(webView);
this.webView.loadUrl(webViewUrl);
messageTextView.setVisibility(View.GONE);
}
else{
messageTextView.setText("Host is invalid.");
}
}
}
//Code to handle back button - Redirect to home page on back pressed
public void onBackButtonClick (View view){
// onBackPressed(); // Navigate back to the previous activity
Intent backtohome = new Intent(this, NavigationDrawer_Dashboard.class);
startActivity(backtohome);
}
//Code to handle back button - Redirect to home page on back pressed

private void setupwebview (WebView webView){
webView.setWebViewClient(new WebViewClient());
webView.setWebChromeClient(new WebChromeClient());
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setAllowUniversalAccessFromFileURLs(true);
}
public void onBackButtonClick (View view){
// onBackPressed(); // Navigate back to the previous activity
Intent backtohome = new Intent(this, NavigationDrawer_Dashboard.class);
startActivity(backtohome);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ public class AddressReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {

Toast.makeText(context.getApplicationContext(), "address hacker changes", Toast.LENGTH_SHORT).show();
Toast.makeText(context.getApplicationContext(), "your address changed", Toast.LENGTH_SHORT).show();
}
}

0 comments on commit ae3f1ca

Please sign in to comment.