imageview
This commit is contained in:
parent
0d388cb6e6
commit
9200a7715a
@ -34,6 +34,7 @@ dependencies {
|
||||
implementation 'com.google.android.material:material:1.7.0'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
|
||||
implementation 'com.squareup.okhttp3:okhttp:4.10.0'
|
||||
implementation 'com.squareup.picasso:picasso:2.71828'
|
||||
testImplementation 'junit:junit:4.13.2'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
|
||||
|
@ -2,6 +2,8 @@ package fr.svpro.rsd;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.media.AudioAttributes;
|
||||
import android.media.AudioManager;
|
||||
import android.media.MediaPlayer;
|
||||
@ -13,6 +15,7 @@ import android.widget.AdapterView;
|
||||
import android.widget.Button;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ListAdapter;
|
||||
import android.widget.ListView;
|
||||
import android.widget.RadioButton;
|
||||
@ -22,11 +25,15 @@ import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import com.squareup.picasso.Picasso;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.security.KeyManagementException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.cert.CertificateException;
|
||||
@ -57,9 +64,8 @@ public class MainActivity extends AppCompatActivity {
|
||||
private Button bRecherche, bShare, bSite;
|
||||
public RadioButton rechNom, rechPays;
|
||||
public String siteWeb;
|
||||
private String nomStation;
|
||||
private String streamURL;
|
||||
private String byFiltre;
|
||||
private String nomStation, streamURL, byFiltre, faviconURL;
|
||||
public ImageView ivLogo;
|
||||
ArrayList<HashMap<String, String>> arrayList;
|
||||
|
||||
|
||||
@ -77,6 +83,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
bSite = (Button) findViewById(R.id.siteWeb);
|
||||
rechNom = (RadioButton) findViewById(R.id.rech_nom);
|
||||
rechPays = (RadioButton) findViewById(R.id.rech_pays);
|
||||
ivLogo = (ImageView) findViewById(R.id.ivLogo);
|
||||
|
||||
bRecherche.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
@ -138,10 +145,12 @@ public class MainActivity extends AppCompatActivity {
|
||||
String name = object.getString("name");
|
||||
String homepage = object.getString("homepage");
|
||||
String url = object.getString("url");
|
||||
String favicon = object.getString("favicon");
|
||||
HashMap<String, String> data = new HashMap<>();
|
||||
data.put("name", name);
|
||||
data.put("homepage", homepage);
|
||||
data.put("url", url);
|
||||
data.put("favicon", favicon);
|
||||
arrayList.add(data);
|
||||
ListAdapter adapter = new SimpleAdapter(MainActivity.this, arrayList, R.layout.list_items
|
||||
, new String[]{"name", "homepage", "url"}, new int[]{R.id.name, R.id.homepage, R.id.url});
|
||||
@ -156,9 +165,15 @@ public class MainActivity extends AppCompatActivity {
|
||||
public void onItemClick(AdapterView<?> parent, View view,
|
||||
int position, long id) {
|
||||
|
||||
nomStation = arrayList.get(position).get("name");// here you have to pas keyname which is put inyour Hashmap arraylist
|
||||
nomStation = arrayList.get(position).get("name");
|
||||
siteWeb = arrayList.get(position).get("homepage");
|
||||
streamURL = arrayList.get(position).get("url");
|
||||
faviconURL = arrayList.get(position).get("favicon");
|
||||
if (Objects.requireNonNull(arrayList.get(position).get("favicon")).isEmpty()) {
|
||||
Picasso.get().load(R.drawable.ic_launcher_foreground).into(ivLogo);
|
||||
} else {
|
||||
Picasso.get().load(faviconURL).into(ivLogo);
|
||||
}
|
||||
|
||||
setTitle(nomStation);
|
||||
bShare.setVisibility(View.VISIBLE);
|
||||
|
@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
@ -90,6 +91,13 @@
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivLogo"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="100dp"
|
||||
android:layout_gravity="center"
|
||||
android:src="@drawable/ic_launcher_foreground" />
|
||||
|
||||
<ListView
|
||||
android:id="@+id/listView"
|
||||
android:layout_width="match_parent"
|
||||
|
Loading…
x
Reference in New Issue
Block a user