From 0b144b9b7d609ffa73beadd08e0ecf21f9ba4a56 Mon Sep 17 00:00:00 2001 From: NudeDude Date: Sun, 24 Dec 2017 17:00:49 +0100 Subject: [PATCH] Major Enhancements --- .../twidda/Engine/ImageDownloader.java | 2 +- .../twidda/Engine/ProfileInformation.java | 23 ++++++++++++++++--- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/org/nuclearfog/twidda/Engine/ImageDownloader.java b/app/src/main/java/org/nuclearfog/twidda/Engine/ImageDownloader.java index 4c10a4c5..29b63496 100644 --- a/app/src/main/java/org/nuclearfog/twidda/Engine/ImageDownloader.java +++ b/app/src/main/java/org/nuclearfog/twidda/Engine/ImageDownloader.java @@ -13,7 +13,7 @@ public class ImageDownloader extends AsyncTask { private ImageView imgView; - public ImageDownloader( ImageView imgView){ + public ImageDownloader(ImageView imgView){ this.imgView = imgView; } diff --git a/app/src/main/java/org/nuclearfog/twidda/Engine/ProfileInformation.java b/app/src/main/java/org/nuclearfog/twidda/Engine/ProfileInformation.java index 39c24282..41ae8105 100644 --- a/app/src/main/java/org/nuclearfog/twidda/Engine/ProfileInformation.java +++ b/app/src/main/java/org/nuclearfog/twidda/Engine/ProfileInformation.java @@ -1,7 +1,9 @@ package org.nuclearfog.twidda.Engine; import android.content.Context; +import android.content.SharedPreferences; import android.os.AsyncTask; +import android.widget.ImageView; import android.widget.TextView; import org.nuclearfog.twidda.R; @@ -12,16 +14,20 @@ import twitter4j.User; public class ProfileInformation extends AsyncTask { - private Context context,toClass; private String screenName, username, description, location, follower, following; private TextView txtUser,txtScrName, txtBio,txtLocation,txtFollowing,txtFollower; + private ImageView profile, banner; + private String imageLink, bannerLink; + private Context context; + private boolean imgEnabled = false; /** * @param context "this" Context */ public ProfileInformation(Context context) { this.context=context; - this.toClass = toClass; + SharedPreferences settings = context.getSharedPreferences("settings", 0); + imgEnabled = settings.getBoolean("image_load",false); } @@ -33,11 +39,13 @@ public class ProfileInformation extends AsyncTask txtLocation = (TextView)((Profile)context).findViewById(R.id.location); txtFollowing = (TextView)((Profile)context).findViewById(R.id.following); txtFollower = (TextView)((Profile)context).findViewById(R.id.follower); + profile = (ImageView)((Profile)context).findViewById(R.id.profile_img); + banner = (ImageView)((Profile)context).findViewById(R.id.banner); } /** - * @param args [0] Username + * @param args [0] Twitter User ID */ @Override protected Void doInBackground(Long... args) { @@ -51,6 +59,8 @@ public class ProfileInformation extends AsyncTask location = user.getLocation(); follower = "Follower: "+ user.getFollowersCount(); following = "Following: "+user.getFriendsCount(); + imageLink = user.getProfileImageURL(); + bannerLink = user.getProfileBannerURL(); } catch(Exception err){err.printStackTrace();} return null; } @@ -58,11 +68,18 @@ public class ProfileInformation extends AsyncTask @Override protected void onPostExecute(Void v) { + ImageDownloader profileImg, bannerImg; txtUser.setText(username); txtScrName.setText(screenName); txtBio.setText(description); txtLocation.setText(location); txtFollower.setText(follower); txtFollowing.setText(following); + profileImg = new ImageDownloader(profile); + bannerImg = new ImageDownloader(banner); + if(imgEnabled) { + profileImg.execute(imageLink); + bannerImg.execute(bannerLink); + } } } \ No newline at end of file