|
1 | 1 | package com.sakarsh.akarshseggemuresume;
|
2 | 2 |
|
| 3 | +import android.content.Intent; |
| 4 | +import android.net.Uri; |
3 | 5 | import android.support.v7.app.AppCompatActivity;
|
4 | 6 | import android.os.Bundle;
|
5 | 7 | import android.util.Log;
|
| 8 | +import android.view.View; |
| 9 | +import android.widget.AdapterView; |
6 | 10 | import android.widget.ListView;
|
7 | 11 |
|
8 | 12 | import com.google.gson.Gson;
|
@@ -35,11 +39,28 @@ protected void onCreate(Bundle savedInstanceState) {
|
35 | 39 | String jsonString = bundle.getString("profiles");
|
36 | 40 | Gson gson = new Gson();
|
37 | 41 | Type listOfProfiles = new TypeToken<List<Profile>>() {}.getType();
|
38 |
| - List<Profile> profileArrayList = gson.fromJson(jsonString, listOfProfiles); |
| 42 | + final List<Profile> profileArrayList = gson.fromJson(jsonString, listOfProfiles); |
39 | 43 | // Log.i("Profiles", "profiles array: "+profileArrayList);
|
40 | 44 |
|
41 | 45 | ProfilesListAdapter profilesListAdapter = new ProfilesListAdapter(this, profileArrayList, imagesOfProfilesArrays);
|
42 | 46 | listView = findViewById(R.id.listView);
|
43 | 47 | listView.setAdapter(profilesListAdapter);
|
| 48 | + |
| 49 | + listView.setOnItemClickListener(new AdapterView.OnItemClickListener(){ |
| 50 | + @Override |
| 51 | + public void onItemClick(AdapterView<?> parent, View view, int position, long id) { |
| 52 | +// URL is being parsed and set to uri |
| 53 | + Uri uri = Uri.parse(profileArrayList.get(position).getUrl()); |
| 54 | +// Intent is declared |
| 55 | + Intent intent = new Intent(Intent.ACTION_VIEW); |
| 56 | +// parsed URL is set to the intent |
| 57 | + intent.setData(uri); |
| 58 | +// Using string resource to show the text. |
| 59 | + String title = (String) getResources().getText(R.string.chooser_title); |
| 60 | +// Create and start chooser to show list of all browser apps installed on the device |
| 61 | + Intent chooser = Intent.createChooser(intent, title); |
| 62 | + startActivity(chooser); |
| 63 | + } |
| 64 | + }); |
44 | 65 | }
|
45 | 66 | }
|
0 commit comments