diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/profile/ProfileActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/profile/ProfileActivity.java index 0c73e611..c85795d0 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/profile/ProfileActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/profile/ProfileActivity.java @@ -2,21 +2,19 @@ package gr.thmmy.mthmmy.activities.profile; import android.content.DialogInterface; import android.content.Intent; -import android.content.SharedPreferences; import android.os.AsyncTask; -import android.os.Build; import android.os.Bundle; import android.support.design.widget.FloatingActionButton; +import android.support.design.widget.TabLayout; +import android.support.v4.app.Fragment; +import android.support.v4.app.FragmentManager; +import android.support.v4.app.FragmentPagerAdapter; import android.support.v4.content.res.ResourcesCompat; import android.support.v4.view.ViewPager; import android.support.v7.app.AlertDialog; import android.support.v7.widget.Toolbar; -import android.text.Html; -import android.util.Log; import android.view.View; -import android.webkit.WebView; import android.widget.ImageView; -import android.widget.LinearLayout; import android.widget.ProgressBar; import android.widget.TextView; import android.widget.Toast; @@ -25,64 +23,65 @@ import com.squareup.picasso.Picasso; import org.jsoup.Jsoup; import org.jsoup.nodes.Document; +import org.jsoup.nodes.Element; import java.util.ArrayList; +import java.util.List; import javax.net.ssl.SSLHandshakeException; import gr.thmmy.mthmmy.R; import gr.thmmy.mthmmy.activities.LoginActivity; import gr.thmmy.mthmmy.activities.base.BaseActivity; +import gr.thmmy.mthmmy.activities.profile.summary.SummaryFragment; import gr.thmmy.mthmmy.utils.CircleTransform; import me.zhanghai.android.materialprogressbar.MaterialProgressBar; import mthmmy.utils.Report; import okhttp3.Request; import okhttp3.Response; -import static gr.thmmy.mthmmy.activities.profile.ProfileParser.PERSONAL_TEXT_INDEX; -import static gr.thmmy.mthmmy.activities.profile.ProfileParser.THUMBNAIL_URL_INDEX; -import static gr.thmmy.mthmmy.activities.profile.ProfileParser.USERNAME_INDEX; -import static gr.thmmy.mthmmy.activities.profile.ProfileParser.parseProfileSummary; -import static gr.thmmy.mthmmy.session.SessionManager.LOGGED_IN; - /** - * Activity for user's profile. When creating an Intent of this activity you need to bundle a String - * containing this user's profile url using the key {@link #EXTRAS_PROFILE_URL}. + * Activity for user profile. When creating an Intent of this activity you need to bundle a String + * containing this user's profile url using the key {@link #BUNDLE_PROFILE_URL}, a String containing + * this user's avatar url and a String containing the username. */ public class ProfileActivity extends BaseActivity { - //Graphic element variables - private ImageView userThumbnail; - private TextView userName; - private TextView personalText; + //Graphics + private TextView personalTextView; private MaterialProgressBar progressBar; private FloatingActionButton replyFAB; private ViewPager viewPager; - - //Other variables + //Other variables and constants /** * Debug Tag for logging debug output to LogCat */ @SuppressWarnings("unused") private static final String TAG = "ProfileActivity"; - static String PACKAGE_NAME; /** * The key to use when putting profile's url String to {@link ProfileActivity}'s Bundle. */ - public static final String EXTRAS_PROFILE_URL = "PROFILE_URL"; + public static final String BUNDLE_PROFILE_URL = "PROFILE_URL"; /** - * {@link ArrayList} of Strings used to hold profile's information. Data are added in {@link ProfileTask}. + * The key to use when putting user's thumbnail url String to {@link ProfileActivity}'s Bundle. + * If user doesn't have a thumbnail put an empty string. */ - private ArrayList parsedProfileData; - private ProfileTask profileTask; + public static final String BUNDLE_THUMBNAIL_URL = "THUMBNAIL_URL"; + /** + * The key to use when putting username String to {@link ProfileActivity}'s Bundle. + */ + public static final String BUNDLE_USERNAME = "USERNAME"; private static final int THUMBNAIL_SIZE = 200; + private ProfileTask profileTask; + private String personalText; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_profile); - PACKAGE_NAME = getApplicationContext().getPackageName(); Bundle extras = getIntent().getExtras(); + String thumbnailUrl = extras.getString(BUNDLE_THUMBNAIL_URL); + String username = extras.getString(BUNDLE_USERNAME); //Initializes graphic elements toolbar = (Toolbar) findViewById(R.id.toolbar); @@ -97,9 +96,24 @@ public class ProfileActivity extends BaseActivity { progressBar = (MaterialProgressBar) findViewById(R.id.progressBar); - userThumbnail = (ImageView) findViewById(R.id.user_thumbnail); - userName = (TextView) findViewById(R.id.profile_activity_username); - personalText = (TextView) findViewById(R.id.profile_activity_personal_text); + ImageView thumbnailView = (ImageView) findViewById(R.id.user_thumbnail); + if (thumbnailUrl != null) + //noinspection ConstantConditions + Picasso.with(this) + .load(thumbnailUrl) + .resize(THUMBNAIL_SIZE, THUMBNAIL_SIZE) + .centerCrop() + .error(ResourcesCompat.getDrawable(this.getResources() + , R.drawable.ic_default_user_thumbnail, null)) + .placeholder(ResourcesCompat.getDrawable(this.getResources() + , R.drawable.ic_default_user_thumbnail, null)) + .transform(new CircleTransform()) + .into(thumbnailView); + TextView usernameView = (TextView) findViewById(R.id.profile_activity_username); + usernameView.setText(username); + personalTextView = (TextView) findViewById(R.id.profile_activity_personal_text); + + viewPager = (ViewPager) findViewById(R.id.profile_tab_container); replyFAB = (FloatingActionButton) findViewById(R.id.profile_fab); //TODO hide fab while logged out replyFAB.setEnabled(false); @@ -131,10 +145,8 @@ public class ProfileActivity extends BaseActivity { } }); - //Gets info - parsedProfileData = new ArrayList<>(); profileTask = new ProfileTask(); - profileTask.execute(extras.getString(EXTRAS_PROFILE_URL)); //Attempt data parsing + profileTask.execute(extras.getString(BUNDLE_PROFILE_URL)); //Attempt data parsing } @Override @@ -145,19 +157,19 @@ public class ProfileActivity extends BaseActivity { } /** - * An {@link AsyncTask} that handles asynchronous fetching of a profile page and parsing it's - * data. {@link AsyncTask#onPostExecute(Object) OnPostExecute} method calls {@link #populateLayout()} - * to build graphics. - *

- *

Calling ProfileSummaryTask's {@link AsyncTask#execute execute} method needs to have profile's url - * as String parameter!

+ * An {@link AsyncTask} that handles asynchronous fetching of a profile page and parsing this + * user's personal text. + *

ProfileTask's {@link AsyncTask#execute execute} method needs a profile's url as String + * parameter!

*/ public class ProfileTask extends AsyncTask { //Class variables /** * Debug Tag for logging debug output to LogCat */ - private static final String TAG = "TopicTask"; //Separate tag for AsyncTask + @SuppressWarnings("unused") + private static final String TAG = "ProfileTask"; //Separate tag for AsyncTask + Document profilePage; protected void onPreExecute() { progressBar.setVisibility(ProgressBar.VISIBLE); @@ -165,7 +177,6 @@ public class ProfileActivity extends BaseActivity { } protected Boolean doInBackground(String... profileUrl) { - Document document; String pageUrl = profileUrl[0] + ";wap"; //Profile's page wap url Request request = new Request.Builder() @@ -173,10 +184,18 @@ public class ProfileActivity extends BaseActivity { .build(); try { Response response = client.newCall(request).execute(); - document = Jsoup.parse(response.body().string()); - //long parseStartTime = System.nanoTime(); - parsedProfileData = parseProfileSummary(document); - //long parseEndTime = System.nanoTime(); + profilePage = Jsoup.parse(response.body().string()); + { //Finds personal text + Element tmpEl = profilePage.select("td.windowbg:nth-child(2)").first(); + if (tmpEl != null) { + personalText = tmpEl.text().trim(); + } else { + //Should never get here! + //Something is wrong. + Report.e(TAG, "An error occurred while trying to find profile's personal text."); + personalText = null; + } + } return true; } catch (SSLHandshakeException e) { Report.w(TAG, "Certificate problem (please switch to unsafe connection)."); @@ -194,36 +213,55 @@ public class ProfileActivity extends BaseActivity { } //Parse was successful progressBar.setVisibility(ProgressBar.INVISIBLE); - populateLayout(); + + if (personalText != null) { + personalTextView.setVisibility(View.VISIBLE); + personalTextView.setText(personalText); + } else { + personalTextView.setVisibility(View.GONE); + } + + setupViewPager(viewPager, profilePage); + TabLayout tabLayout = (TabLayout) findViewById(R.id.profile_tabs); + tabLayout.setupWithViewPager(viewPager); } } /** - * Simple method that builds the UI of a {@link ProfileActivity}. - *

Use this method only after parsing profile's data with {@link ProfileTask} as it - * reads from {@link #parsedProfileData}

+ * Simple method that sets up the {@link ViewPager} of a {@link ProfileActivity} + * @param viewPager the ViewPager to be setup + * @param profilePage this profile's parsed page */ - private void populateLayout() { - if (parsedProfileData.get(THUMBNAIL_URL_INDEX) != null) - //noinspection ConstantConditions - Picasso.with(this) - .load(parsedProfileData.get(THUMBNAIL_URL_INDEX)) - .resize(THUMBNAIL_SIZE, THUMBNAIL_SIZE) - .centerCrop() - .error(ResourcesCompat.getDrawable(this.getResources() - , R.drawable.ic_default_user_thumbnail, null)) - .placeholder(ResourcesCompat.getDrawable(this.getResources() - , R.drawable.ic_default_user_thumbnail, null)) - .transform(new CircleTransform()) - .into(userThumbnail); + private void setupViewPager(ViewPager viewPager, Document profilePage) { + ViewPagerAdapter adapter = new ViewPagerAdapter(getSupportFragmentManager()); + adapter.addFrag(SummaryFragment.newInstance(profilePage), "SUMMARY"); + //adapter.addFrag(new ); + //adapter.addFrag(new ); + viewPager.setAdapter(adapter); + } - userName.setText(parsedProfileData.get(USERNAME_INDEX)); + class ViewPagerAdapter extends FragmentPagerAdapter { + private final List mFragmentList = new ArrayList<>(); + private final List mFragmentTitleList = new ArrayList<>(); - if (parsedProfileData.get(PERSONAL_TEXT_INDEX) != null) { - personalText.setVisibility(View.VISIBLE); - personalText.setText(parsedProfileData.get(PERSONAL_TEXT_INDEX)); - } else { - personalText.setVisibility(View.GONE); + ViewPagerAdapter(FragmentManager manager) { + super(manager); + } + @Override + public Fragment getItem(int position) { + return mFragmentList.get(position); + } + @Override + public int getCount() { + return mFragmentList.size(); + } + void addFrag(Fragment fragment, String title) { + mFragmentList.add(fragment); + mFragmentTitleList.add(title); + } + @Override + public CharSequence getPageTitle(int position) { + return mFragmentTitleList.get(position); } } } diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/profile/ProfileParser.java b/app/src/main/java/gr/thmmy/mthmmy/activities/profile/ProfileParser.java deleted file mode 100644 index fab4e120..00000000 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/profile/ProfileParser.java +++ /dev/null @@ -1,143 +0,0 @@ -package gr.thmmy.mthmmy.activities.profile; - -import org.jsoup.nodes.Document; -import org.jsoup.nodes.Element; -import org.jsoup.select.Elements; - -import java.util.ArrayList; -import java.util.Objects; - -import mthmmy.utils.Report; - -import static gr.thmmy.mthmmy.activities.profile.ProfileActivity.PACKAGE_NAME; - -/** - * Singleton used for parsing user's profile. - *

Class contains the methods:

  • {@link #parseProfileSummary(Document)}
  • - *

- */ -class ProfileParser { - /** - * Debug Tag for logging debug output to LogCat - */ - @SuppressWarnings("unused") - private static final String TAG = "ProfileParser"; - /** - * Index of user's thumbnail url in parsed information ArrayList - *

Not the url itself!

- */ - static final int THUMBNAIL_URL_INDEX = 0; - /** - * Index of user's username in parsed information ArrayList - *

Not the username itself!

- */ - static final int USERNAME_INDEX = 1; - /** - * Index of user's personal text in parsed information ArrayList - *

Not the text itself!

- */ - static final int PERSONAL_TEXT_INDEX = 2; - - /** - * Returns an {@link ArrayList} of {@link String}s. This method is used to parse all available - * information in a user profile. - *

- * User's thumbnail image url, username and personal text are placed at Array's indexes defined - * by public constants THUMBNAIL_URL_INDEX, USERNAME_INDEX and PERSONAL_TEXT_INDEX respectively. - * - * @param profile {@link Document} object containing this profile's source code - * @return ArrayList containing this profile's parsed information - * @see org.jsoup.Jsoup Jsoup - */ - static ArrayList parseProfileSummary(Document profile) { - //Method's variables - ArrayList parsedInformation = new ArrayList<>(); - - //Contains all summary's rows - Elements summaryRows = profile.select(".bordercolor > tbody:nth-child(1) > tr:nth-child(2) tr"); - - { //Finds thumbnail's url - Element tmpEl = profile.select(".bordercolor img.avatar").first(); - if (tmpEl != null) - parsedInformation.add(THUMBNAIL_URL_INDEX, tmpEl.attr("abs:src")); - else //User doesn't have an avatar - parsedInformation.add(THUMBNAIL_URL_INDEX, null); - } - - { //Finds username - Element tmpEl = summaryRows.first(); - if (tmpEl != null) { - parsedInformation.add(USERNAME_INDEX, tmpEl.select("td").get(1).text()); - } else { - //Should never get here! - //Something is wrong. - Report.e(PACKAGE_NAME + "." + TAG, "An error occurred while trying to find profile's username."); - parsedInformation.add(USERNAME_INDEX, null); - } - } - - { //Finds personal text - Element tmpEl = profile.select("td.windowbg:nth-child(2)").first(); - if (tmpEl != null) { - String tmpPersonalText = tmpEl.text().trim(); - parsedInformation.add(PERSONAL_TEXT_INDEX, tmpPersonalText); - } else { - //Should never get here! - //Something is wrong. - Report.e(PACKAGE_NAME + "." + TAG, "An error occurred while trying to find profile's personal text."); - parsedInformation.add(PERSONAL_TEXT_INDEX, null); - } - } - - for (Element row : summaryRows) { - String rowText = row.text(), pHtml = ""; - - //Horizontal rule rows - if (row.select("td").size() == 1) - pHtml = ""; - else if (rowText.contains("Signature") || rowText.contains("Υπογραφή")) { - //This needs special handling since it may have css - { //Fix embedded videos - Elements noembedTag = row.select("noembed"); - ArrayList embededVideosUrls = new ArrayList<>(); - - for (Element _noembed : noembedTag) { - embededVideosUrls.add(_noembed.text().substring(_noembed.text() - .indexOf("href=\"https://www.youtube.com/watch?") + 38 - , _noembed.text().indexOf("target") - 2)); - } - - pHtml = row.html(); - - int tmp_counter = 0; - while (pHtml.contains(" embededVideosUrls.size()) - break; - pHtml = pHtml.replace( - pHtml.substring(pHtml.indexOf("") + 9) - , "

" - + "" - + "\"\"" - + "" - //+ "" - + "
"); - } - } - - //Add stuff to make it work in WebView - //style.css - pHtml = ("" + pHtml); - } else if (!rowText.contains("Name") && !rowText.contains("Όνομα")) { //Don't add username twice - if (Objects.equals(row.select("td").get(1).text(), "")) - continue; - //Style parsed information with html - pHtml = "" + row.select("td").first().text() + " " - + row.select("td").get(1).text(); - } - parsedInformation.add(pHtml); - } - return parsedInformation; - } -} diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/profile/summary/SummaryFragment.java b/app/src/main/java/gr/thmmy/mthmmy/activities/profile/summary/SummaryFragment.java index c5b41d62..a5776d10 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/profile/summary/SummaryFragment.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/profile/summary/SummaryFragment.java @@ -3,6 +3,7 @@ package gr.thmmy.mthmmy.activities.profile.summary; import android.os.AsyncTask; import android.os.Build; import android.os.Bundle; +import android.support.v4.app.Fragment; import android.text.Html; import android.util.Log; import android.view.LayoutInflater; @@ -21,45 +22,48 @@ import java.util.ArrayList; import java.util.Objects; import gr.thmmy.mthmmy.R; -import gr.thmmy.mthmmy.activities.base.BaseFragment; import gr.thmmy.mthmmy.activities.profile.ProfileActivity; -import me.zhanghai.android.materialprogressbar.MaterialProgressBar; import mthmmy.utils.Report; /** - * A {@link BaseFragment} subclass. - * Use the {@link SummaryFragment#newInstance} factory method to - * create an instance of this fragment. + * Use the {@link SummaryFragment#newInstance} factory method to create an instance of this fragment. */ -public class SummaryFragment extends BaseFragment { - static final String PROFILE_DOCUMENT = "PROFILE_DOCUMENT"; +public class SummaryFragment extends Fragment { + /** + * Debug Tag for logging debug output to LogCat + */ + @SuppressWarnings("unused") private static final String TAG = "SummaryFragment"; + /** + * The key to use when putting profile's source code String to {@link SummaryFragment}'s Bundle. + */ + static final String PROFILE_DOCUMENT = "PROFILE_DOCUMENT"; /** * {@link ArrayList} of Strings used to hold profile's information. Data are added in {@link ProfileActivity.ProfileTask}. */ + private ArrayList parsedProfileSummaryData; + /** + * A {@link Document} holding this profile's source code. + */ private Document profileSummaryDocument; private ProfileSummaryTask profileSummaryTask; - private ArrayList parsedProfileSummaryData; private LinearLayout mainContent; - private MaterialProgressBar progressBar; public SummaryFragment() { // Required empty public constructor - this.profileSummaryDocument = Jsoup.parse(getArguments().getString(PROFILE_DOCUMENT)); } /** - * Use ONLY this factory method to create a new instance of - * this fragment using the provided parameters. + * Use ONLY this factory method to create a new instance of this fragment using the provided + * parameters. * + * @param profileSummaryDocument a {@link Document} containing this profile's parsed page * @return A new instance of fragment Summary. */ - public static SummaryFragment newInstance(int sectionNumber, Document profileSummaryDocument) { + public static SummaryFragment newInstance(Document profileSummaryDocument) { SummaryFragment fragment = new SummaryFragment(); Bundle args = new Bundle(); - args.putString(ARG_TAG, TAG); - args.putInt(ARG_SECTION_NUMBER, sectionNumber); args.putString(PROFILE_DOCUMENT, profileSummaryDocument.toString()); fragment.setArguments(args); return fragment; @@ -68,6 +72,7 @@ public class SummaryFragment extends BaseFragment { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + profileSummaryDocument = Jsoup.parse(getArguments().getString(PROFILE_DOCUMENT)); parsedProfileSummaryData = new ArrayList<>(); } @@ -77,7 +82,6 @@ public class SummaryFragment extends BaseFragment { if (parsedProfileSummaryData.isEmpty()) { profileSummaryTask = new ProfileSummaryTask(); profileSummaryTask.execute(profileSummaryDocument); - } Report.d(TAG, "onActivityCreated"); } @@ -93,15 +97,13 @@ public class SummaryFragment extends BaseFragment { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View rootView = inflater.inflate(R.layout.profile_fragment_summary, container, false); - progressBar = (MaterialProgressBar) rootView.findViewById(R.id.progressBar); mainContent = (LinearLayout) rootView.findViewById(R.id.profile_activity_content); - populateLayout(); return rootView; } /** - * An {@link AsyncTask} that handles asynchronous fetching of a profile page and parsing it's - * data. {@link AsyncTask#onPostExecute(Object) OnPostExecute} method calls {@link #populateLayout()} + * An {@link AsyncTask} that handles asynchronous parsing of a profile page's data. + * {@link AsyncTask#onPostExecute(Object) OnPostExecute} method calls {@link #populateLayout()} * to build graphics. *

*

Calling ProfileSummaryTask's {@link AsyncTask#execute execute} method needs to have profile's url @@ -112,28 +114,20 @@ public class SummaryFragment extends BaseFragment { /** * Debug Tag for logging debug output to LogCat */ + @SuppressWarnings("unused") private static final String TAG = "TopicTask"; //Separate tag for AsyncTask - protected void onPreExecute() { - progressBar.setVisibility(MaterialProgressBar.VISIBLE); - } - protected Void doInBackground(Document... profileSummaryPage) { parsedProfileSummaryData = parseProfileSummary(profileSummaryPage[0]); return null; } protected void onPostExecute(Void result) { - progressBar.setVisibility(MaterialProgressBar.INVISIBLE); populateLayout(); } /** - * Returns an {@link ArrayList} of {@link String}s. This method is used to parse all available - * information in a user profile. - *

- * User's thumbnail image url, username and personal text are placed at Array's indexes defined - * by public constants THUMBNAIL_URL_INDEX, USERNAME_INDEX and PERSONAL_TEXT_INDEX respectively. + * This method is used to parse all available information in a user profile. * * @param profile {@link Document} object containing this profile's source code * @return ArrayList containing this profile's parsed information @@ -200,7 +194,7 @@ public class SummaryFragment extends BaseFragment { } /** - * Simple method that builds the UI of a {@link ProfileActivity}. + * Simple method that builds the UI of a {@link SummaryFragment}. *

Use this method only after parsing profile's data with * {@link gr.thmmy.mthmmy.activities.profile.ProfileActivity.ProfileTask} as it reads from * {@link #parsedProfileSummaryData}

@@ -210,7 +204,8 @@ public class SummaryFragment extends BaseFragment { if (profileSummaryRow.contains("Signature") || profileSummaryRow.contains("Υπογραφή")) { WebView signatureEntry = new WebView(this.getContext()); - signatureEntry.loadDataWithBaseURL("file:///android_asset/", profileSummaryRow, "text/html", "UTF-8", null); + signatureEntry.loadDataWithBaseURL("file:///android_asset/", profileSummaryRow, + "text/html", "UTF-8", null); } TextView entry = new TextView(this.getContext()); diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java index 27267f12..b80c4f77 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java @@ -50,7 +50,9 @@ import me.zhanghai.android.materialprogressbar.MaterialProgressBar; import mthmmy.utils.Report; import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK; -import static gr.thmmy.mthmmy.activities.profile.ProfileActivity.EXTRAS_PROFILE_URL; +import static gr.thmmy.mthmmy.activities.profile.ProfileActivity.BUNDLE_PROFILE_URL; +import static gr.thmmy.mthmmy.activities.profile.ProfileActivity.BUNDLE_THUMBNAIL_URL; +import static gr.thmmy.mthmmy.activities.profile.ProfileActivity.BUNDLE_USERNAME; import static gr.thmmy.mthmmy.activities.topic.TopicActivity.base_url; import static gr.thmmy.mthmmy.activities.topic.TopicActivity.toQuoteList; @@ -310,9 +312,14 @@ class TopicAdapter extends RecyclerView.Adapter { if (viewProperties.get(holder.getAdapterPosition())[isUserExtraInfoVisibile]) { Intent intent = new Intent(context, ProfileActivity.class); - Bundle b = new Bundle(); - b.putString(EXTRAS_PROFILE_URL, currentPost.getProfileURL()); - intent.putExtras(b); + Bundle extras = new Bundle(); + extras.putString(BUNDLE_PROFILE_URL, currentPost.getProfileURL()); + if(currentPost.getThumbnailUrl() == null) + extras.putString(BUNDLE_THUMBNAIL_URL, ""); + else + extras.putString(BUNDLE_THUMBNAIL_URL, currentPost.getThumbnailUrl()); + extras.putString(BUNDLE_USERNAME, currentPost.getAuthor()); + intent.putExtras(extras); intent.setFlags(FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent); } diff --git a/app/src/main/res/layout-v21/activity_profile.xml b/app/src/main/res/layout-v21/activity_profile.xml index aaaec83b..7601b753 100644 --- a/app/src/main/res/layout-v21/activity_profile.xml +++ b/app/src/main/res/layout-v21/activity_profile.xml @@ -95,7 +95,7 @@ android:layout_height="wrap_content" android:indeterminate="true" android:visibility="invisible" - app:layout_anchor="@id/nested_scroll" + app:layout_anchor="@id/profile_tab_container" app:layout_anchorGravity="top|center" app:mpb_indeterminateTint="@color/accent" app:mpb_progressStyle="horizontal"/> diff --git a/app/src/main/res/layout/activity_profile.xml b/app/src/main/res/layout/activity_profile.xml index 43032e29..47599ee8 100644 --- a/app/src/main/res/layout/activity_profile.xml +++ b/app/src/main/res/layout/activity_profile.xml @@ -97,7 +97,7 @@ android:layout_height="wrap_content" android:indeterminate="true" android:visibility="invisible" - app:layout_anchor="@id/nested_scroll" + app:layout_anchor="@id/profile_tab_container" app:layout_anchorGravity="top|center" app:mpb_indeterminateTint="@color/accent" app:mpb_progressStyle="horizontal"/> diff --git a/app/src/main/res/layout/profile_fragment_latest_posts_row.xml b/app/src/main/res/layout/profile_fragment_latest_posts_row.xml new file mode 100644 index 00000000..fb3d8a25 --- /dev/null +++ b/app/src/main/res/layout/profile_fragment_latest_posts_row.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/profile_fragment_summary.xml b/app/src/main/res/layout/profile_fragment_summary.xml index 0b8b479f..7a5a14a1 100644 --- a/app/src/main/res/layout/profile_fragment_summary.xml +++ b/app/src/main/res/layout/profile_fragment_summary.xml @@ -1,36 +1,19 @@ - + android:layout_height="match_parent" + android:background="@color/background" + android:paddingEnd="16dp" + android:paddingStart="16dp" + android:scrollbars="none"> - - - - - - - - \ No newline at end of file + android:gravity="center" + android:orientation="vertical"> + + \ No newline at end of file