blob: 8e0b7893da77cd336197926242668389856217b2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
package de.thedevstack.conversationsplus.ui.listeners;
import android.app.Activity;
import android.content.Intent;
import android.view.View;
import android.widget.Toast;
import de.thedevstack.conversationsplus.R;
import de.thedevstack.conversationsplus.entities.Message;
import de.thedevstack.conversationsplus.utils.GeoHelper;
/**
*/
public class OpenLocationOnClickListener implements View.OnClickListener {
private final Activity activity;
private final Message message;
public OpenLocationOnClickListener(Activity activity, Message message) {
this.activity = activity;
this.message = message;
}
@Override
public void onClick(View view) {
this.showLocation();
}
private void showLocation() {
for (Intent intent : GeoHelper.createGeoIntentsFromMessage(this.message)) {
if (intent.resolveActivity(this.activity.getPackageManager()) != null) { // Only if the intent can be opened
this.activity.startActivity(intent);
return;
}
}
Toast.makeText(this.activity, R.string.no_application_found_to_display_location, Toast.LENGTH_SHORT).show();
}
}
|