From b536f1ccc57beadd11d21097c5458cef7c274dbe Mon Sep 17 00:00:00 2001 From: NudeDude Date: Sun, 12 May 2019 01:42:25 +0200 Subject: [PATCH] layout bug fix --- .../twidda/backend/ProfileLoader.java | 87 +++++++++---------- app/src/main/res/layout/item_tweet.xml | 1 - 2 files changed, 43 insertions(+), 45 deletions(-) diff --git a/app/src/main/java/org/nuclearfog/twidda/backend/ProfileLoader.java b/app/src/main/java/org/nuclearfog/twidda/backend/ProfileLoader.java index 1844e8e1..10eab70c 100644 --- a/app/src/main/java/org/nuclearfog/twidda/backend/ProfileLoader.java +++ b/app/src/main/java/org/nuclearfog/twidda/backend/ProfileLoader.java @@ -53,8 +53,8 @@ public class ProfileLoader extends AsyncTask { private int highlight; private boolean imgEnabled; private boolean isHome; - private boolean isFollowing; - private boolean isFollowed; + private boolean isFriend; + private boolean isFollower; private boolean isBlocked; private boolean isMuted; private boolean canDm; @@ -96,8 +96,8 @@ public class ProfileLoader extends AsyncTask { if (!isHome) { boolean[] connection = mTwitter.getConnection(UID); - isFollowing = connection[0]; - isFollowed = connection[1]; + isFriend = connection[0]; + isFollower = connection[1]; isBlocked = connection[2]; isMuted = connection[3]; canDm = connection[4]; @@ -106,17 +106,17 @@ public class ProfileLoader extends AsyncTask { switch (mode) { case ACTION_FOLLOW: if (user.isLocked()) { - if (isFollowing) + if (isFriend) user = mTwitter.unfollowUser(UID); else if (!user.followRequested()) user = mTwitter.followUser(UID); // TODO purge follow request } else { - if (!isFollowing) + if (!isFriend) user = mTwitter.followUser(UID); else user = mTwitter.unfollowUser(UID); - isFollowing = !isFollowing; + isFriend = !isFriend; } publishProgress(); break; @@ -155,6 +155,7 @@ public class ProfileLoader extends AsyncTask { protected void onProgressUpdate(Void... v) { if (ui.get() == null) return; + ImageView profile = ui.get().findViewById(R.id.profile_img); TextView txtUser = ui.get().findViewById(R.id.profile_username); TextView txtScrName = ui.get().findViewById(R.id.profile_screenname); TextView txtBio = ui.get().findViewById(R.id.bio); @@ -162,49 +163,37 @@ public class ProfileLoader extends AsyncTask { TextView txtLink = ui.get().findViewById(R.id.links); TextView txtFollowing = ui.get().findViewById(R.id.following); TextView txtFollower = ui.get().findViewById(R.id.follower); - ImageView profile = ui.get().findViewById(R.id.profile_img); + TextView txtCreated = ui.get().findViewById(R.id.profile_date); View location_ico = ui.get().findViewById(R.id.loction_ico); View link_ico = ui.get().findViewById(R.id.links_ico); + View locked = ui.get().findViewById(R.id.profile_locked); + View verified = ui.get().findViewById(R.id.profile_verify); + View following = ui.get().findViewById(R.id.followback); + View profile_head = ui.get().findViewById(R.id.profile_header); - if (mode == Mode.LDR_PROFILE) { - View profile_head = ui.get().findViewById(R.id.profile_header); - if (profile_head.getVisibility() != VISIBLE) { - profile_head.setVisibility(VISIBLE); - - View verified = ui.get().findViewById(R.id.profile_verify); - View followback = ui.get().findViewById(R.id.followback); - View locked = ui.get().findViewById(R.id.profile_locked); - TextView txtCreated = ui.get().findViewById(R.id.profile_date); - String date = sdf.format(new Date(user.getCreatedAt())); - txtCreated.setText(date); - - if (user.isVerified()) - verified.setVisibility(VISIBLE); - if (isFollowed) - followback.setVisibility(VISIBLE); - if (user.isLocked()) { - locked.setVisibility(VISIBLE); - } - profile.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - Intent image = new Intent(ui.get(), ImageDetail.class); - image.putExtra("link", new String[]{user.getImageLink()}); - image.putExtra("storable", true); - ui.get().startActivity(image); - - } - }); - } - } Spanned bio = Tagger.makeText(user.getBio(), highlight, ui.get()); txtBio.setMovementMethod(LinkMovementMethod.getInstance()); - txtBio.setText(bio); txtUser.setText(user.getUsername()); txtScrName.setText(user.getScreenname()); txtFollower.setText(formatter.format(user.getFollower())); txtFollowing.setText(formatter.format(user.getFollowing())); - + String date = sdf.format(new Date(user.getCreatedAt())); + txtCreated.setText(date); + txtBio.setText(bio); + if (profile_head.getVisibility() != VISIBLE) + profile_head.setVisibility(VISIBLE); + if (isFollower) + following.setVisibility(VISIBLE); + else + following.setVisibility(GONE); + if (user.isVerified()) + verified.setVisibility(VISIBLE); + else + verified.setVisibility(GONE); + if (user.isLocked()) + locked.setVisibility(VISIBLE); + else + locked.setVisibility(GONE); if (user.getLocation() != null && !user.getLocation().isEmpty()) { txtLocation.setText(user.getLocation()); txtLocation.setVisibility(VISIBLE); @@ -225,7 +214,17 @@ public class ProfileLoader extends AsyncTask { String link = user.getImageLink() + "_bigger"; Picasso.get().load(link).into(profile); } - + if (!profile.isClickable()) { + profile.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Intent image = new Intent(ui.get(), ImageDetail.class); + image.putExtra("link", new String[]{user.getImageLink()}); + image.putExtra("storable", true); + ui.get().startActivity(image); + } + }); + } ui.get().setTweetCount(user.getTweetCount(), user.getFavorCount()); } @@ -238,7 +237,7 @@ public class ProfileLoader extends AsyncTask { switch (mode) { case ACTION_FOLLOW: if (!user.isLocked()) - if (isFollowing) + if (isFriend) Toast.makeText(ui.get(), R.string.followed, Toast.LENGTH_SHORT).show(); else Toast.makeText(ui.get(), R.string.unfollowed, Toast.LENGTH_SHORT).show(); @@ -259,7 +258,7 @@ public class ProfileLoader extends AsyncTask { break; } if (!isHome) { - ui.get().setConnection(isFollowing, isMuted, isBlocked, user.isLocked(), canDm, user.followRequested()); + ui.get().setConnection(isFriend, isMuted, isBlocked, user.isLocked(), canDm, user.followRequested()); ui.get().invalidateOptionsMenu(); } } else { diff --git a/app/src/main/res/layout/item_tweet.xml b/app/src/main/res/layout/item_tweet.xml index 28c7b5d7..c9d52f3a 100644 --- a/app/src/main/res/layout/item_tweet.xml +++ b/app/src/main/res/layout/item_tweet.xml @@ -87,7 +87,6 @@ android:layout_gravity="center_vertical" android:layout_marginEnd="@dimen/icon_margin" android:layout_marginRight="@dimen/icon_margin" - android:layout_weight="1" android:contentDescription="@string/verify" android:visibility="gone" app:srcCompat="@drawable/lock" />