From 39b79ca5fadaa42588d71a5b6dc0495590e57915 Mon Sep 17 00:00:00 2001 From: Ezerous Date: Tue, 25 Jul 2017 14:17:11 +0300 Subject: [PATCH 1/6] Up tools & gradle --- .gitlab-ci.yml | 4 ++-- app/build.gradle | 16 ++++++++-------- build.gradle | 1 + 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b3c840ca..851425b8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,8 +1,8 @@ image: openjdk:8-jdk variables: - ANDROID_TARGET_SDK: "25" - ANDROID_BUILD_TOOLS: "25.0.3" + ANDROID_TARGET_SDK: "26" + ANDROID_BUILD_TOOLS: "26.0.1" ANDROID_SDK_TOOLS: "25.2.5" before_script: diff --git a/app/build.gradle b/app/build.gradle index cc50d899..69de9530 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,14 +1,14 @@ apply plugin: 'com.android.application' android { - compileSdkVersion 25 - buildToolsVersion "25.0.3" + compileSdkVersion 26 + buildToolsVersion "26.0.1" defaultConfig { vectorDrawables.useSupportLibrary = true applicationId "gr.thmmy.mthmmy" minSdkVersion 19 - targetSdkVersion 25 + targetSdkVersion 26 versionCode 8 versionName "1.3.0" archivesBaseName = "mTHMMY-v$versionName" @@ -28,11 +28,11 @@ android { dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) - compile 'com.android.support:appcompat-v7:25.3.1' - compile 'com.android.support:design:25.3.1' - compile 'com.android.support:support-v4:25.3.1' - compile 'com.android.support:cardview-v7:25.3.1' - compile 'com.android.support:recyclerview-v7:25.3.1' + compile 'com.android.support:appcompat-v7:26.0.0' + compile 'com.android.support:design:26.0.0' + compile 'com.android.support:support-v4:26.0.0' + compile 'com.android.support:cardview-v7:26.0.0' + compile 'com.android.support:recyclerview-v7:26.0.0' compile 'com.google.firebase:firebase-crash:10.2.6' compile 'com.squareup.okhttp3:okhttp:3.8.0' compile 'com.squareup.picasso:picasso:2.5.2' diff --git a/build.gradle b/build.gradle index d786c62a..41691e53 100644 --- a/build.gradle +++ b/build.gradle @@ -17,6 +17,7 @@ allprojects { repositories { jcenter() maven { url "https://jitpack.io" } + maven { url "https://maven.google.com" } } } From 1cac15844c86a4d5a9991bbbb6160cd840295875 Mon Sep 17 00:00:00 2001 From: Ezerous Date: Tue, 25 Jul 2017 14:21:08 +0300 Subject: [PATCH 2/6] Code cleanup --- .../mthmmy/activities/AboutActivity.java | 13 +++-- .../mthmmy/activities/BookmarkActivity.java | 5 +- .../mthmmy/activities/LoginActivity.java | 12 ++--- .../activities/board/BoardActivity.java | 9 ++-- .../mthmmy/activities/board/BoardAdapter.java | 30 +++++------ .../downloads/DownloadsActivity.java | 9 ++-- .../downloads/DownloadsAdapter.java | 18 +++---- .../mthmmy/activities/main/MainActivity.java | 4 +- .../activities/main/forum/ForumAdapter.java | 4 +- .../activities/main/forum/ForumFragment.java | 6 +-- .../activities/main/recent/RecentAdapter.java | 6 +-- .../main/recent/RecentFragment.java | 6 +-- .../activities/main/unread/UnreadAdapter.java | 10 ++-- .../main/unread/UnreadFragment.java | 6 +-- .../activities/profile/ProfileActivity.java | 17 +++---- .../latestPosts/LatestPostsAdapter.java | 10 ++-- .../latestPosts/LatestPostsFragment.java | 4 +- .../profile/stats/StatsFragment.java | 10 ++-- .../profile/summary/SummaryFragment.java | 2 +- .../activities/topic/TopicActivity.java | 27 +++++----- .../mthmmy/activities/topic/TopicAdapter.java | 50 +++++++++---------- 21 files changed, 126 insertions(+), 132 deletions(-) diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/AboutActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/AboutActivity.java index dd90a6df..3f23909b 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/AboutActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/AboutActivity.java @@ -6,7 +6,6 @@ import android.support.design.widget.AppBarLayout; import android.support.design.widget.CoordinatorLayout; import android.support.v4.widget.DrawerLayout; import android.support.v7.app.AlertDialog; -import android.support.v7.widget.Toolbar; import android.view.LayoutInflater; import android.view.View; import android.webkit.WebView; @@ -36,10 +35,10 @@ public class AboutActivity extends BaseActivity { String versionName = BuildConfig.VERSION_NAME; //Initialize appbar - appBar = (AppBarLayout) findViewById(R.id.appbar); - coordinatorLayout = (CoordinatorLayout) findViewById(R.id.main_content); + appBar = findViewById(R.id.appbar); + coordinatorLayout = findViewById(R.id.main_content); //Initialize toolbar - toolbar = (Toolbar) findViewById(R.id.toolbar); + toolbar = findViewById(R.id.toolbar); toolbar.setTitle(R.string.about); setSupportActionBar(toolbar); if (getSupportActionBar() != null) { @@ -50,10 +49,10 @@ public class AboutActivity extends BaseActivity { createDrawer(); drawer.setSelection(ABOUT_ID); - final ScrollView mainContent = (ScrollView) findViewById(R.id.scrollview); - trollGif = (FrameLayout) findViewById(R.id.trollPicFrame); + final ScrollView mainContent = findViewById(R.id.scrollview); + trollGif = findViewById(R.id.trollPicFrame); - TextView tv = (TextView) findViewById(R.id.version); + TextView tv = findViewById(R.id.version); if (tv != null) tv.setText(getString(R.string.version, versionName)); diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/BookmarkActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/BookmarkActivity.java index d010eb8f..ddc076ff 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/BookmarkActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/BookmarkActivity.java @@ -4,7 +4,6 @@ import android.content.Intent; import android.graphics.Typeface; import android.os.Build; import android.os.Bundle; -import android.support.v7.widget.Toolbar; import android.view.LayoutInflater; import android.view.View; import android.widget.LinearLayout; @@ -34,7 +33,7 @@ public class BookmarkActivity extends BaseActivity { setContentView(R.layout.activity_bookmark); //Initialize toolbar - toolbar = (Toolbar) findViewById(R.id.toolbar); + toolbar = findViewById(R.id.toolbar); toolbar.setTitle("Bookmarks"); setSupportActionBar(toolbar); if (getSupportActionBar() != null) { @@ -45,7 +44,7 @@ public class BookmarkActivity extends BaseActivity { createDrawer(); drawer.setSelection(BOOKMARKS_ID); - LinearLayout bookmarksLinearView = (LinearLayout) findViewById(R.id.bookmarks_container); + LinearLayout bookmarksLinearView = findViewById(R.id.bookmarks_container); LayoutInflater layoutInflater = getLayoutInflater(); if(!getBoardsBookmarked().isEmpty()) { diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/LoginActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/LoginActivity.java index 460b0b0d..dddd0158 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/LoginActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/LoginActivity.java @@ -42,10 +42,10 @@ public class LoginActivity extends BaseActivity { setContentView(R.layout.activity_login); //Variables initialization - inputUsername = (EditText) findViewById(R.id.username); - inputPassword = (EditText) findViewById(R.id.password); - btnLogin = (AppCompatButton) findViewById(R.id.btnLogin); - AppCompatButton btnGuest = (AppCompatButton) findViewById(R.id.btnContinueAsGuest); + inputUsername = findViewById(R.id.username); + inputPassword = findViewById(R.id.password); + btnLogin = findViewById(R.id.btnLogin); + AppCompatButton btnGuest = findViewById(R.id.btnContinueAsGuest); //Login button Click Event btnLogin.setOnClickListener(new View.OnClickListener() { @@ -138,8 +138,8 @@ public class LoginActivity extends BaseActivity { protected void onPreExecute() { //Show a progress dialog until done btnLogin.setEnabled(false); //Login button shouldn't be pressed during this - spinner = (LinearLayout) findViewById(R.id.login_progress_bar); - loginContent = (ScrollView) findViewById(R.id.inner_scroll_view); + spinner = findViewById(R.id.login_progress_bar); + loginContent = findViewById(R.id.inner_scroll_view); View view = getCurrentFocus(); if (view != null) { diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardActivity.java index 633ab6ec..9ffc55c5 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardActivity.java @@ -7,7 +7,6 @@ import android.support.design.widget.FloatingActionButton; import android.support.v7.widget.DividerItemDecoration; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; -import android.support.v7.widget.Toolbar; import android.util.Log; import android.view.View; import android.widget.ImageButton; @@ -76,7 +75,7 @@ public class BoardActivity extends BaseActivity implements BoardAdapter.OnLoadMo } //Initializes graphics - toolbar = (Toolbar) findViewById(R.id.toolbar); + toolbar = findViewById(R.id.toolbar); if (boardTitle != null && !Objects.equals(boardTitle, "")) toolbar.setTitle(boardTitle); else toolbar.setTitle("Board"); setSupportActionBar(toolbar); @@ -89,8 +88,8 @@ public class BoardActivity extends BaseActivity implements BoardAdapter.OnLoadMo setBoardBookmark((ImageButton) findViewById(R.id.bookmark)); createDrawer(); - progressBar = (MaterialProgressBar) findViewById(R.id.progressBar); - newTopicFAB = (FloatingActionButton) findViewById(R.id.board_fab); + progressBar = findViewById(R.id.progressBar); + newTopicFAB = findViewById(R.id.board_fab); newTopicFAB.setEnabled(false); newTopicFAB.hide(); /*if (!sessionManager.isLoggedIn()) newTopicFAB.hide(); @@ -124,7 +123,7 @@ public class BoardActivity extends BaseActivity implements BoardAdapter.OnLoadMo }*/ boardAdapter = new BoardAdapter(getApplicationContext(), parsedSubBoards, parsedTopics); - RecyclerView mainContent = (RecyclerView) findViewById(R.id.board_recycler_view); + RecyclerView mainContent = findViewById(R.id.board_recycler_view); mainContent.setAdapter(boardAdapter); final LinearLayoutManager layoutManager = new LinearLayoutManager(this); mainContent.setLayoutManager(layoutManager); diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardAdapter.java b/app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardAdapter.java index b6b716be..bb43c065 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardAdapter.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardAdapter.java @@ -275,13 +275,13 @@ class BoardAdapter extends RecyclerView.Adapter { SubBoardViewHolder(View board) { super(board); - boardRow = (LinearLayout) board.findViewById(R.id.child_board_row); - boardExpandable = (LinearLayout) board.findViewById(R.id.child_board_expandable); - showHideExpandable = (ImageButton) board.findViewById(R.id.child_board_expand_collapse_button); - boardTitle = (TextView) board.findViewById(R.id.child_board_title); - boardMods = (TextView) board.findViewById(R.id.child_board_mods); - boardStats = (TextView) board.findViewById(R.id.child_board_stats); - boardLastPost = (TextView) board.findViewById(R.id.child_board_last_post); + boardRow = board.findViewById(R.id.child_board_row); + boardExpandable = board.findViewById(R.id.child_board_expandable); + showHideExpandable = board.findViewById(R.id.child_board_expand_collapse_button); + boardTitle = board.findViewById(R.id.child_board_title); + boardMods = board.findViewById(R.id.child_board_mods); + boardStats = board.findViewById(R.id.child_board_stats); + boardLastPost = board.findViewById(R.id.child_board_last_post); } } @@ -292,13 +292,13 @@ class BoardAdapter extends RecyclerView.Adapter { TopicViewHolder(View topic) { super(topic); - topicRow = (LinearLayout) topic.findViewById(R.id.topic_row_linear); - topicExpandable = (LinearLayout) topic.findViewById(R.id.topic_expandable); - showHideExpandable = (ImageButton) topic.findViewById(R.id.topic_expand_collapse_button); - topicSubject = (TextView) topic.findViewById(R.id.topic_subject); - topicStartedBy = (TextView) topic.findViewById(R.id.topic_started_by); - topicStats = (TextView) topic.findViewById(R.id.topic_stats); - topicLastPost = (TextView) topic.findViewById(R.id.topic_last_post); + topicRow = topic.findViewById(R.id.topic_row_linear); + topicExpandable = topic.findViewById(R.id.topic_expandable); + showHideExpandable = topic.findViewById(R.id.topic_expand_collapse_button); + topicSubject = topic.findViewById(R.id.topic_subject); + topicStartedBy = topic.findViewById(R.id.topic_started_by); + topicStats = topic.findViewById(R.id.topic_stats); + topicLastPost = topic.findViewById(R.id.topic_last_post); } } @@ -313,7 +313,7 @@ class BoardAdapter extends RecyclerView.Adapter { LoadingViewHolder(View itemView) { super(itemView); - progressBar = (MaterialProgressBar) itemView.findViewById(R.id.recycler_progress_bar); + progressBar = itemView.findViewById(R.id.recycler_progress_bar); } } } diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/downloads/DownloadsActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/downloads/DownloadsActivity.java index 8c944f7f..292c4050 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/downloads/DownloadsActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/downloads/DownloadsActivity.java @@ -7,7 +7,6 @@ import android.support.design.widget.FloatingActionButton; import android.support.v7.widget.DividerItemDecoration; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; -import android.support.v7.widget.Toolbar; import android.view.View; import android.widget.ProgressBar; import android.widget.Toast; @@ -75,7 +74,7 @@ public class DownloadsActivity extends BaseActivity implements DownloadsAdapter. } else downloadsUrl = downloadsIndexUrl; //Initialize toolbar - toolbar = (Toolbar) findViewById(R.id.toolbar); + toolbar = findViewById(R.id.toolbar); if (downloadsTitle == null || Objects.equals(downloadsTitle, "")) toolbar.setTitle("Downloads"); toolbar.setTitle(downloadsTitle); @@ -88,9 +87,9 @@ public class DownloadsActivity extends BaseActivity implements DownloadsAdapter. createDrawer(); drawer.setSelection(DOWNLOADS_ID); - progressBar = (MaterialProgressBar) findViewById(R.id.progressBar); + progressBar = findViewById(R.id.progressBar); - recyclerView = (RecyclerView) findViewById(R.id.downloads_recycler_view); + recyclerView = findViewById(R.id.downloads_recycler_view); recyclerView.setHasFixedSize(true); final LinearLayoutManager layoutManager = new LinearLayoutManager(getApplicationContext()); recyclerView.setLayoutManager(layoutManager); @@ -113,7 +112,7 @@ public class DownloadsActivity extends BaseActivity implements DownloadsAdapter. } }); - uploadFAB = (FloatingActionButton) findViewById(R.id.download_fab); + uploadFAB = findViewById(R.id.download_fab); uploadFAB.setEnabled(false); uploadFAB.hide(); diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/downloads/DownloadsAdapter.java b/app/src/main/java/gr/thmmy/mthmmy/activities/downloads/DownloadsAdapter.java index 0253359b..7a7bf17f 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/downloads/DownloadsAdapter.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/downloads/DownloadsAdapter.java @@ -174,14 +174,14 @@ class DownloadsAdapter extends RecyclerView.Adapter { DownloadViewHolder(View download) { super(download); - upperLinear = (LinearLayout) download.findViewById(R.id.upper_linear); - downloadRow = (LinearLayout) download.findViewById(R.id.download_row); - informationExpandable = (LinearLayout) download.findViewById(R.id.child_board_expandable); - title = (TextView) download.findViewById(R.id.download_title); - subTitle = (TextView) download.findViewById(R.id.download_sub_title); - uploaderDate = (TextView) download.findViewById(R.id.download_extra_info); - extraInfo = (TextView) download.findViewById(R.id.download_uploader_date); - informationExpandableBtn = (ImageButton) download.findViewById(R.id.download_information_button); + upperLinear = download.findViewById(R.id.upper_linear); + downloadRow = download.findViewById(R.id.download_row); + informationExpandable = download.findViewById(R.id.child_board_expandable); + title = download.findViewById(R.id.download_title); + subTitle = download.findViewById(R.id.download_sub_title); + uploaderDate = download.findViewById(R.id.download_extra_info); + extraInfo = download.findViewById(R.id.download_uploader_date); + informationExpandableBtn = download.findViewById(R.id.download_information_button); } } @@ -190,7 +190,7 @@ class DownloadsAdapter extends RecyclerView.Adapter { LoadingViewHolder(View itemView) { super(itemView); - progressBar = (MaterialProgressBar) itemView.findViewById(R.id.recycler_progress_bar); + progressBar = itemView.findViewById(R.id.recycler_progress_bar); } } } diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/main/MainActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/main/MainActivity.java index 9e665182..6fca5c7f 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/main/MainActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/main/MainActivity.java @@ -73,10 +73,10 @@ public class MainActivity extends BaseActivity implements RecentFragment.RecentF //Set up the ViewPager with the sections adapter. - viewPager = (ViewPager) findViewById(R.id.container); + viewPager = findViewById(R.id.container); viewPager.setAdapter(sectionsPagerAdapter); - TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs); + TabLayout tabLayout = findViewById(R.id.tabs); tabLayout.setupWithViewPager(viewPager); setMainActivity(this); diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/main/forum/ForumAdapter.java b/app/src/main/java/gr/thmmy/mthmmy/activities/main/forum/ForumAdapter.java index 821c83a5..5b2f4c93 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/main/forum/ForumAdapter.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/main/forum/ForumAdapter.java @@ -70,7 +70,7 @@ class ForumAdapter extends ExpandableRecyclerAdapter { ViewHolder(View view) { super(view); mView = view; - mTitleView = (TextView) view.findViewById(R.id.title); - mUserView = (TextView) view.findViewById(R.id.lastUser); - mDateTimeView = (TextView) view.findViewById(R.id.dateTime); + mTitleView = view.findViewById(R.id.title); + mUserView = view.findViewById(R.id.lastUser); + mDateTimeView = view.findViewById(R.id.dateTime); } } } diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/main/recent/RecentFragment.java b/app/src/main/java/gr/thmmy/mthmmy/activities/main/recent/RecentFragment.java index 86e3a2d2..89aa027b 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/main/recent/RecentFragment.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/main/recent/RecentFragment.java @@ -95,10 +95,10 @@ public class RecentFragment extends BaseFragment { // Set the adapter if (rootView instanceof RelativeLayout) { - progressBar = (MaterialProgressBar) rootView.findViewById(R.id.progressBar); + progressBar = rootView.findViewById(R.id.progressBar); recentAdapter = new RecentAdapter(getActivity(), topicSummaries, fragmentInteractionListener); - CustomRecyclerView recyclerView = (CustomRecyclerView) rootView.findViewById(R.id.list); + CustomRecyclerView recyclerView = rootView.findViewById(R.id.list); LinearLayoutManager linearLayoutManager = new LinearLayoutManager(rootView.findViewById(R.id.list).getContext()); recyclerView.setLayoutManager(linearLayoutManager); DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(recyclerView.getContext(), @@ -106,7 +106,7 @@ public class RecentFragment extends BaseFragment { recyclerView.addItemDecoration(dividerItemDecoration); recyclerView.setAdapter(recentAdapter); - swipeRefreshLayout = (SwipeRefreshLayout) rootView.findViewById(R.id.swiperefresh); + swipeRefreshLayout = rootView.findViewById(R.id.swiperefresh); swipeRefreshLayout.setOnRefreshListener( new SwipeRefreshLayout.OnRefreshListener() { @Override diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/main/unread/UnreadAdapter.java b/app/src/main/java/gr/thmmy/mthmmy/activities/main/unread/UnreadAdapter.java index 73adc1e4..b146a06c 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/main/unread/UnreadAdapter.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/main/unread/UnreadAdapter.java @@ -114,9 +114,9 @@ class UnreadAdapter extends RecyclerView.Adapter { ViewHolder(View view) { super(view); mView = view; - mTitleView = (TextView) view.findViewById(R.id.title); - mUserView = (TextView) view.findViewById(R.id.lastUser); - mDateTimeView = (TextView) view.findViewById(R.id.dateTime); + mTitleView = view.findViewById(R.id.title); + mUserView = view.findViewById(R.id.lastUser); + mDateTimeView = view.findViewById(R.id.dateTime); } } @@ -125,7 +125,7 @@ class UnreadAdapter extends RecyclerView.Adapter { EmptyViewHolder(View view) { super(view); - text = (TextView) view.findViewById(R.id.text); + text = view.findViewById(R.id.text); } } @@ -137,7 +137,7 @@ class UnreadAdapter extends RecyclerView.Adapter { MarkReadViewHolder(View view) { super(view); mView = view; - text = (TextView) view.findViewById(R.id.mark_read); + text = view.findViewById(R.id.mark_read); } } diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/main/unread/UnreadFragment.java b/app/src/main/java/gr/thmmy/mthmmy/activities/main/unread/UnreadFragment.java index d1febe97..5fec960f 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/main/unread/UnreadFragment.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/main/unread/UnreadFragment.java @@ -98,7 +98,7 @@ public class UnreadFragment extends BaseFragment { // Set the adapter if (rootView instanceof RelativeLayout) { - progressBar = (MaterialProgressBar) rootView.findViewById(R.id.progressBar); + progressBar = rootView.findViewById(R.id.progressBar); unreadAdapter = new UnreadAdapter(getActivity(), topicSummaries, fragmentInteractionListener, new UnreadAdapter.MarkReadInteractionListener() { @Override @@ -110,7 +110,7 @@ public class UnreadFragment extends BaseFragment { } }); - CustomRecyclerView recyclerView = (CustomRecyclerView) rootView.findViewById(R.id.list); + CustomRecyclerView recyclerView = rootView.findViewById(R.id.list); LinearLayoutManager linearLayoutManager = new LinearLayoutManager(rootView.findViewById(R.id.list).getContext()); recyclerView.setLayoutManager(linearLayoutManager); DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(recyclerView.getContext(), @@ -118,7 +118,7 @@ public class UnreadFragment extends BaseFragment { recyclerView.addItemDecoration(dividerItemDecoration); recyclerView.setAdapter(unreadAdapter); - swipeRefreshLayout = (SwipeRefreshLayout) rootView.findViewById(R.id.swiperefresh); + swipeRefreshLayout = rootView.findViewById(R.id.swiperefresh); swipeRefreshLayout.setOnRefreshListener( new SwipeRefreshLayout.OnRefreshListener() { @Override 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 f21a21eb..24600df5 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 @@ -13,7 +13,6 @@ 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.widget.Toolbar; import android.text.Spannable; import android.text.SpannableString; import android.text.Spanned; @@ -105,7 +104,7 @@ public class ProfileActivity extends BaseActivity implements LatestPostsFragment profileUrl = extras.getString(BUNDLE_PROFILE_URL); //Initializes graphic elements - toolbar = (Toolbar) findViewById(R.id.toolbar); + toolbar = findViewById(R.id.toolbar); toolbar.setTitle(null); setSupportActionBar(toolbar); if (getSupportActionBar() != null) { @@ -115,9 +114,9 @@ public class ProfileActivity extends BaseActivity implements LatestPostsFragment createDrawer(); - progressBar = (MaterialProgressBar) findViewById(R.id.progressBar); + progressBar = findViewById(R.id.progressBar); - thumbnailView = (ImageView) findViewById(R.id.user_thumbnail); + thumbnailView = findViewById(R.id.user_thumbnail); if (!Objects.equals(thumbnailUrl, "")) //noinspection ConstantConditions Picasso.with(this) @@ -130,15 +129,15 @@ public class ProfileActivity extends BaseActivity implements LatestPostsFragment , R.drawable.ic_default_user_thumbnail, null)) .transform(new CircleTransform()) .into(thumbnailView); - usernameView = (TextView) findViewById(R.id.profile_activity_username); + usernameView = findViewById(R.id.profile_activity_username); usernameView.setTypeface(Typeface.createFromAsset(this.getAssets() , "fonts/fontawesome-webfont.ttf")); if (username != null && !Objects.equals(username, "")) usernameView.setText(username); - personalTextView = (TextView) findViewById(R.id.profile_activity_personal_text); + personalTextView = findViewById(R.id.profile_activity_personal_text); - viewPager = (ViewPager) findViewById(R.id.profile_tab_container); + viewPager = findViewById(R.id.profile_tab_container); - pmFAB = (FloatingActionButton) findViewById(R.id.profile_fab); + pmFAB = findViewById(R.id.profile_fab); pmFAB.setEnabled(false); pmFAB.hide(); /*if (!sessionManager.isLoggedIn()) pmFAB.hide(); @@ -311,7 +310,7 @@ public class ProfileActivity extends BaseActivity implements LatestPostsFragment } setupViewPager(viewPager, profilePage); - TabLayout tabLayout = (TabLayout) findViewById(R.id.profile_tabs); + TabLayout tabLayout = findViewById(R.id.profile_tabs); tabLayout.setupWithViewPager(viewPager); if (tabSelect != 0) { TabLayout.Tab tab = tabLayout.getTabAt(tabSelect); diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/profile/latestPosts/LatestPostsAdapter.java b/app/src/main/java/gr/thmmy/mthmmy/activities/profile/latestPosts/LatestPostsAdapter.java index 13319607..9a2696ac 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/profile/latestPosts/LatestPostsAdapter.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/profile/latestPosts/LatestPostsAdapter.java @@ -97,10 +97,10 @@ class LatestPostsAdapter extends RecyclerView.Adapter { LatestPostViewHolder(View itemView) { super(itemView); - latestPostsRow = (RelativeLayout) itemView.findViewById(R.id.latest_posts_row); - postTitle = (TextView) itemView.findViewById(R.id.title); - postDate = (TextView) itemView.findViewById(R.id.date); - post = (WebView) itemView.findViewById(R.id.post); + latestPostsRow = itemView.findViewById(R.id.latest_posts_row); + postTitle = itemView.findViewById(R.id.title); + postDate = itemView.findViewById(R.id.date); + post = itemView.findViewById(R.id.post); } } @@ -109,7 +109,7 @@ class LatestPostsAdapter extends RecyclerView.Adapter { LoadingViewHolder(View itemView) { super(itemView); - progressBar = (MaterialProgressBar) itemView.findViewById(R.id.recycler_progress_bar); + progressBar = itemView.findViewById(R.id.recycler_progress_bar); } } } \ No newline at end of file diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/profile/latestPosts/LatestPostsFragment.java b/app/src/main/java/gr/thmmy/mthmmy/activities/profile/latestPosts/LatestPostsFragment.java index 8f39f6c9..2ec45dde 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/profile/latestPosts/LatestPostsFragment.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/profile/latestPosts/LatestPostsFragment.java @@ -84,7 +84,7 @@ public class LatestPostsFragment extends BaseFragment implements LatestPostsAdap Bundle savedInstanceState) { final View rootView = inflater.inflate(R.layout.fragment_latest_posts, container, false); latestPostsAdapter = new LatestPostsAdapter(fragmentInteractionListener, parsedTopicSummaries); - RecyclerView mainContent = (RecyclerView) rootView.findViewById(R.id.profile_latest_posts_recycler); + RecyclerView mainContent = rootView.findViewById(R.id.profile_latest_posts_recycler); mainContent.setAdapter(latestPostsAdapter); final LinearLayoutManager layoutManager = new LinearLayoutManager(getContext()); mainContent.setLayoutManager(layoutManager); @@ -106,7 +106,7 @@ public class LatestPostsFragment extends BaseFragment implements LatestPostsAdap } } }); - progressBar = (MaterialProgressBar) rootView.findViewById(R.id.progressBar); + progressBar = rootView.findViewById(R.id.progressBar); return rootView; } diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/profile/stats/StatsFragment.java b/app/src/main/java/gr/thmmy/mthmmy/activities/profile/stats/StatsFragment.java index 50c8c521..fc1867c0 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/profile/stats/StatsFragment.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/profile/stats/StatsFragment.java @@ -90,8 +90,8 @@ public class StatsFragment extends Fragment { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View rootView = inflater.inflate(R.layout.fragment_stats, container, false); - mainContent = (LinearLayout) rootView.findViewById(R.id.main_content); - progressBar = (MaterialProgressBar) rootView.findViewById(R.id.progressBar); + mainContent = rootView.findViewById(R.id.main_content); + progressBar = rootView.findViewById(R.id.progressBar); if (haveParsed) populateLayout(); return rootView; @@ -224,7 +224,7 @@ public class StatsFragment extends Fragment { ((TextView) mainContent.findViewById(R.id.posting_activity_by_time_title)) .setText(postingActivityByTimeTitle); - LineChart postingActivityByTimeChart = (LineChart) mainContent + LineChart postingActivityByTimeChart = mainContent .findViewById(R.id.posting_activity_by_time_chart); postingActivityByTimeChart.setDescription(null); postingActivityByTimeChart.getLegend().setEnabled(false); @@ -257,7 +257,7 @@ public class StatsFragment extends Fragment { ((TextView) mainContent.findViewById(R.id.most_popular_boards_by_posts_title)) .setText(mostPopularBoardsByPostsTitle); - HorizontalBarChart mostPopularBoardsByPostsChart = (HorizontalBarChart) mainContent. + HorizontalBarChart mostPopularBoardsByPostsChart = mainContent. findViewById(R.id.most_popular_boards_by_posts_chart); mostPopularBoardsByPostsChart.setDescription(null); mostPopularBoardsByPostsChart.getLegend().setEnabled(false); @@ -298,7 +298,7 @@ public class StatsFragment extends Fragment { ((TextView) mainContent.findViewById(R.id.most_popular_boards_by_activity_title)) .setText(mostPopularBoardsByActivityTitle); - HorizontalBarChart mostPopularBoardsByActivityChart = (HorizontalBarChart) mainContent. + HorizontalBarChart mostPopularBoardsByActivityChart = mainContent. findViewById(R.id.most_popular_boards_by_activity_chart); mostPopularBoardsByActivityChart.setDescription(null); mostPopularBoardsByActivityChart.getLegend().setEnabled(false); 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 fc3d4dd7..d77d1180 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 @@ -77,7 +77,7 @@ public class SummaryFragment extends Fragment { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View rootView = inflater.inflate(R.layout.fragment_summary, container, false); - mainContent = (LinearLayout) rootView.findViewById(R.id.profile_activity_content); + mainContent = rootView.findViewById(R.id.profile_activity_content); if (!parsedProfileSummaryData.isEmpty() && isAdded()) populateLayout(); return rootView; diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java index 5c170204..2cc534fc 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java @@ -11,7 +11,6 @@ import android.os.Handler; import android.support.design.widget.FloatingActionButton; import android.support.v7.app.AlertDialog; import android.support.v7.widget.RecyclerView; -import android.support.v7.widget.Toolbar; import android.text.Html; import android.text.SpannableStringBuilder; import android.text.TextUtils; @@ -143,8 +142,8 @@ public class TopicActivity extends BaseActivity { thisPageBookmark = new Bookmark(topicTitle, ThmmyPage.getTopicId(topicPageUrl)); //Initializes graphics - toolbar = (Toolbar) findViewById(R.id.toolbar); - toolbarTitle = (TextView) toolbar.findViewById(R.id.toolbar_title); + toolbar = findViewById(R.id.toolbar); + toolbarTitle = toolbar.findViewById(R.id.toolbar_title); toolbarTitle.setSingleLine(true); toolbarTitle.setEllipsize(TextUtils.TruncateAt.MARQUEE); toolbarTitle.setMarqueeRepeatLimit(-1); @@ -162,11 +161,11 @@ public class TopicActivity extends BaseActivity { createDrawer(); - progressBar = (MaterialProgressBar) findViewById(R.id.progressBar); + progressBar = findViewById(R.id.progressBar); postsList = new ArrayList<>(); - recyclerView = (RecyclerView) findViewById(R.id.topic_recycler_view); + recyclerView = findViewById(R.id.topic_recycler_view); recyclerView.setHasFixedSize(true); recyclerView.setOnTouchListener( new View.OnTouchListener() { @@ -183,9 +182,9 @@ public class TopicActivity extends BaseActivity { topicAdapter = new TopicAdapter(this, postsList, topicTask); recyclerView.setAdapter(topicAdapter); - replyFAB = (FloatingActionButton) findViewById(R.id.topic_fab); + replyFAB = findViewById(R.id.topic_fab); replyFAB.setEnabled(false); - bottomNavBar = (LinearLayout) findViewById(R.id.bottom_navigation_bar); + bottomNavBar = findViewById(R.id.bottom_navigation_bar); if (!sessionManager.isLoggedIn()) replyFAB.hide(); else { replyFAB.setOnClickListener(new View.OnClickListener() { @@ -204,11 +203,11 @@ public class TopicActivity extends BaseActivity { } //Sets bottom navigation bar - firstPage = (ImageButton) findViewById(R.id.page_first_button); - previousPage = (ImageButton) findViewById(R.id.page_previous_button); - pageIndicator = (TextView) findViewById(R.id.page_indicator); - nextPage = (ImageButton) findViewById(R.id.page_next_button); - lastPage = (ImageButton) findViewById(R.id.page_last_button); + firstPage = findViewById(R.id.page_first_button); + previousPage = findViewById(R.id.page_previous_button); + pageIndicator = findViewById(R.id.page_indicator); + nextPage = findViewById(R.id.page_next_button); + lastPage = findViewById(R.id.page_last_button); initDecrementButton(firstPage, LARGE_STEP); initDecrementButton(previousPage, SMALL_STEP); @@ -243,10 +242,10 @@ public class TopicActivity extends BaseActivity { LinearLayout infoDialog = (LinearLayout) inflater.inflate(R.layout.dialog_topic_info , null); ((TextView) infoDialog.findViewById(R.id.dialog_title)).setText("Info"); - TextView treeAndMods = (TextView) infoDialog.findViewById(R.id.topic_tree_and_mods); + TextView treeAndMods = infoDialog.findViewById(R.id.topic_tree_and_mods); treeAndMods.setText(topicTreeAndMods); treeAndMods.setMovementMethod(LinkMovementMethod.getInstance()); - TextView usersViewing = (TextView) infoDialog.findViewById(R.id.users_viewing); + TextView usersViewing = infoDialog.findViewById(R.id.users_viewing); usersViewing.setText(topicViewers); usersViewing.setMovementMethod(LinkMovementMethod.getInstance()); 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 aa17b311..64526741 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 @@ -139,7 +139,7 @@ class TopicAdapter extends RecyclerView.Adapter { inflate(R.layout.activity_topic_quick_reply_row, parent, false); view.findViewById(R.id.quick_reply_submit).setEnabled(true); - final EditText quickReplyText = (EditText) view.findViewById(R.id.quick_reply_text); + final EditText quickReplyText = view.findViewById(R.id.quick_reply_text); quickReplyText.setFocusableInTouchMode(true); quickReplyText.setOnFocusChangeListener(new View.OnFocusChangeListener() { @Override @@ -511,29 +511,29 @@ class TopicAdapter extends RecyclerView.Adapter { super(view); //Initializes layout's graphic elements //Standard stuff - cardView = (CardView) view.findViewById(R.id.card_view); - cardChildLinear = (LinearLayout) view.findViewById(R.id.card_child_linear); - postDateAndNumber = (FrameLayout) view.findViewById(R.id.post_date_and_number_exp); - postDate = (TextView) view.findViewById(R.id.post_date); - postNum = (TextView) view.findViewById(R.id.post_number); - thumbnail = (ImageView) view.findViewById(R.id.thumbnail); - username = (TextView) view.findViewById(R.id.username); - subject = (TextView) view.findViewById(R.id.subject); - post = (WebView) view.findViewById(R.id.post); + cardView = view.findViewById(R.id.card_view); + cardChildLinear = view.findViewById(R.id.card_child_linear); + postDateAndNumber = view.findViewById(R.id.post_date_and_number_exp); + postDate = view.findViewById(R.id.post_date); + postNum = view.findViewById(R.id.post_number); + thumbnail = view.findViewById(R.id.thumbnail); + username = view.findViewById(R.id.username); + subject = view.findViewById(R.id.subject); + post = view.findViewById(R.id.post); post.setBackgroundColor(Color.argb(1, 255, 255, 255)); - quoteToggle = (ImageButton) view.findViewById(R.id.toggle_quote_button); + quoteToggle = view.findViewById(R.id.toggle_quote_button); bodyFooterDivider = view.findViewById(R.id.body_footer_divider); - postFooter = (LinearLayout) view.findViewById(R.id.post_footer); + postFooter = view.findViewById(R.id.post_footer); //User's extra info - header = (RelativeLayout) view.findViewById(R.id.header); - userExtraInfo = (LinearLayout) view.findViewById(R.id.user_extra_info); - specialRank = (TextView) view.findViewById(R.id.special_rank); - rank = (TextView) view.findViewById(R.id.rank); - gender = (TextView) view.findViewById(R.id.gender); - numberOfPosts = (TextView) view.findViewById(R.id.number_of_posts); - personalText = (TextView) view.findViewById(R.id.personal_text); - stars = (TextView) view.findViewById(R.id.stars); + header = view.findViewById(R.id.header); + userExtraInfo = view.findViewById(R.id.user_extra_info); + specialRank = view.findViewById(R.id.special_rank); + rank = view.findViewById(R.id.rank); + gender = view.findViewById(R.id.gender); + numberOfPosts = view.findViewById(R.id.number_of_posts); + personalText = view.findViewById(R.id.personal_text); + stars = view.findViewById(R.id.stars); } } @@ -550,15 +550,15 @@ class TopicAdapter extends RecyclerView.Adapter { QuickReplyViewHolder(View quickReply, CustomEditTextListener replySubject , CustomEditTextListener replyText) { super(quickReply); - thumbnail = (ImageView) quickReply.findViewById(R.id.thumbnail); - username = (TextView) quickReply.findViewById(R.id.username); - this.quickReply = (EditText) quickReply.findViewById(R.id.quick_reply_text); + thumbnail = quickReply.findViewById(R.id.thumbnail); + username = quickReply.findViewById(R.id.username); + this.quickReply = quickReply.findViewById(R.id.quick_reply_text); this.replyText = replyText; this.quickReply.addTextChangedListener(replyText); - quickReplySubject = (EditText) quickReply.findViewById(R.id.quick_reply_subject); + quickReplySubject = quickReply.findViewById(R.id.quick_reply_subject); this.replySubject = replySubject; quickReplySubject.addTextChangedListener(replySubject); - submitButton = (AppCompatImageButton) quickReply.findViewById(R.id.quick_reply_submit); + submitButton = quickReply.findViewById(R.id.quick_reply_submit); } } From 56297beaa7efb8a32e2cf15f89ae51b0685d0371 Mon Sep 17 00:00:00 2001 From: Apostolof Date: Tue, 25 Jul 2017 18:04:57 +0300 Subject: [PATCH 3/6] Minor board and topic fixes --- .../thmmy/mthmmy/activities/board/BoardActivity.java | 8 ++++++-- app/src/main/java/gr/thmmy/mthmmy/model/ThmmyPage.java | 10 ++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardActivity.java index 9ffc55c5..742a73b3 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardActivity.java @@ -7,7 +7,6 @@ import android.support.design.widget.FloatingActionButton; import android.support.v7.widget.DividerItemDecoration; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; -import android.util.Log; import android.view.View; import android.widget.ImageButton; import android.widget.ProgressBar; @@ -73,6 +72,12 @@ public class BoardActivity extends BaseActivity implements BoardAdapter.OnLoadMo Toast.makeText(this, "An error has occurred\nAborting.", Toast.LENGTH_SHORT).show(); finish(); } + //Fixes url + { + String tmpUrlSbstr = boardUrl.replaceAll("(.+)(board=)([0-9]*)(\\.*[0-9]*).*", "$1$2$3"); + if (!tmpUrlSbstr.substring(tmpUrlSbstr.indexOf("board=")).contains(".")) + boardUrl = tmpUrlSbstr + ".0"; + } //Initializes graphics toolbar = findViewById(R.id.toolbar); @@ -164,7 +169,6 @@ public class BoardActivity extends BaseActivity implements BoardAdapter.OnLoadMo @Override public void onResume() { super.onResume(); - Log.d("Boardaa", "onResume called!"); refreshBoardBookmark((ImageButton) findViewById(R.id.bookmark)); } diff --git a/app/src/main/java/gr/thmmy/mthmmy/model/ThmmyPage.java b/app/src/main/java/gr/thmmy/mthmmy/model/ThmmyPage.java index 3ca324ed..8962f2b9 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/model/ThmmyPage.java +++ b/app/src/main/java/gr/thmmy/mthmmy/model/ThmmyPage.java @@ -162,7 +162,7 @@ public class ThmmyPage { || Objects.equals(uriString, "https://www.thmmy.gr") || Objects.equals(uriString, "https://www.thmmy.gr/smf/index.php")) return PageCategory.INDEX; - Timber.v("Unknown thmmy link found, link: %s" , uriString); + Timber.v("Unknown thmmy link found, link: %s", uriString); return PageCategory.UNKNOWN_THMMY; } return PageCategory.NOT_THMMY; @@ -172,7 +172,7 @@ public class ThmmyPage { if (resolvePageCategory(Uri.parse(boardUrl)) == PageCategory.BOARD) { String returnString = boardUrl.substring(boardUrl.indexOf("board=") + 6); if (returnString.contains(".")) - returnString = boardUrl.substring(boardUrl.indexOf("board=") + 6, boardUrl.lastIndexOf(".")); + returnString = returnString.substring(0, returnString.indexOf(".")); return returnString; } return null; @@ -180,8 +180,10 @@ public class ThmmyPage { public static String getTopicId(String topicUrl) { if (resolvePageCategory(Uri.parse(topicUrl)) == PageCategory.TOPIC) { - String tmp = topicUrl.substring(topicUrl.indexOf("topic=") + 6); - return tmp.substring(0, tmp.indexOf(".")); + String returnString = topicUrl.substring(topicUrl.indexOf("topic=") + 6); + if (returnString.contains(".")) + returnString = returnString.substring(0, returnString.indexOf(".")); + return returnString; } return null; } From 6763b4d08192f140a538ccae7e9db19d32d540e0 Mon Sep 17 00:00:00 2001 From: Apostolof Date: Tue, 25 Jul 2017 20:14:56 +0300 Subject: [PATCH 4/6] Code cleanup and Downloads hotfix. --- app/src/main/AndroidManifest.xml | 1 - .../mthmmy/activities/main/MainActivity.java | 36 +++++++++---------- .../activities/main/unread/UnreadAdapter.java | 18 +++++----- .../latestPosts/LatestPostsFragment.java | 2 +- .../activities/topic/TopicActivity.java | 33 +++++++++-------- .../gr/thmmy/mthmmy/base/BaseActivity.java | 11 +++--- .../gr/thmmy/mthmmy/base/BaseFragment.java | 5 +-- .../utils/CustomLinearLayoutManager.java | 5 +-- .../mthmmy/utils/ScrollAwareFABBehavior.java | 22 ++++++------ .../utils/ScrollAwareLinearBehavior.java | 15 +++++--- app/src/main/res/layout/dialog_topic_info.xml | 1 + .../layout/fragment_unread_mark_read_row.xml | 1 + 12 files changed, 77 insertions(+), 73 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 8e78f4e6..0ed23714 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -90,7 +90,6 @@ { } @Override - public void onBindViewHolder(RecyclerView.ViewHolder holder, final int position) { + public void onBindViewHolder(final RecyclerView.ViewHolder holder, final int position) { if (holder instanceof UnreadAdapter.EmptyViewHolder) { final UnreadAdapter.EmptyViewHolder emptyViewHolder = (UnreadAdapter.EmptyViewHolder) holder; - emptyViewHolder.text.setText(unreadList.get(position).getDateTimeModified()); + emptyViewHolder.text.setText(unreadList.get(holder.getAdapterPosition()).getDateTimeModified()); } else if (holder instanceof UnreadAdapter.ViewHolder) { final UnreadAdapter.ViewHolder viewHolder = (UnreadAdapter.ViewHolder) holder; - viewHolder.mTitleView.setText(unreadList.get(position).getSubject()); - viewHolder.mDateTimeView.setText(unreadList.get(position).getDateTimeModified()); + viewHolder.mTitleView.setText(unreadList.get(holder.getAdapterPosition()).getSubject()); + viewHolder.mDateTimeView.setText(unreadList.get(holder.getAdapterPosition()).getDateTimeModified()); viewHolder.mUserView.setText(context.getString(R.string.byUser, unreadList.get(position).getLastUser())); - viewHolder.topic = unreadList.get(position); + viewHolder.topic = unreadList.get(holder.getAdapterPosition()); viewHolder.mView.setOnClickListener(new View.OnClickListener() { @Override @@ -83,8 +83,8 @@ class UnreadAdapter extends RecyclerView.Adapter { }); } else if (holder instanceof UnreadAdapter.MarkReadViewHolder) { final UnreadAdapter.MarkReadViewHolder markReadViewHolder = (UnreadAdapter.MarkReadViewHolder) holder; - markReadViewHolder.text.setText(unreadList.get(position).getSubject()); - markReadViewHolder.topic = unreadList.get(position); + markReadViewHolder.text.setText(unreadList.get(holder.getAdapterPosition()).getSubject()); + markReadViewHolder.topic = unreadList.get(holder.getAdapterPosition()); markReadViewHolder.mView.setOnClickListener(new View.OnClickListener() { @Override @@ -92,7 +92,7 @@ class UnreadAdapter extends RecyclerView.Adapter { if (null != mListener) { // Notify the active callbacks interface (the activity, if the // fragment is attached to one) that an item has been selected. - markReadListener.onMarkReadInteraction(unreadList.get(position).getTopicUrl()); + markReadListener.onMarkReadInteraction(unreadList.get(holder.getAdapterPosition()).getTopicUrl()); } } }); @@ -141,7 +141,7 @@ class UnreadAdapter extends RecyclerView.Adapter { } } - public interface MarkReadInteractionListener { + interface MarkReadInteractionListener { void onMarkReadInteraction(String markReadLinkUrl); } } diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/profile/latestPosts/LatestPostsFragment.java b/app/src/main/java/gr/thmmy/mthmmy/activities/profile/latestPosts/LatestPostsFragment.java index 2ec45dde..11cb671e 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/profile/latestPosts/LatestPostsFragment.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/profile/latestPosts/LatestPostsFragment.java @@ -33,7 +33,7 @@ import timber.log.Timber; /** * Use the {@link LatestPostsFragment#newInstance} factory method to create an instance of this fragment. */ -public class LatestPostsFragment extends BaseFragment implements LatestPostsAdapter.OnLoadMoreListener{ +public class LatestPostsFragment extends BaseFragment implements LatestPostsAdapter.OnLoadMoreListener { /** * The key to use when putting profile's url String to {@link LatestPostsFragment}'s Bundle. */ diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java index 2cc534fc..d95b5a7d 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java @@ -241,7 +241,6 @@ public class TopicActivity extends BaseActivity { LayoutInflater inflater = this.getLayoutInflater(); LinearLayout infoDialog = (LinearLayout) inflater.inflate(R.layout.dialog_topic_info , null); - ((TextView) infoDialog.findViewById(R.id.dialog_title)).setText("Info"); TextView treeAndMods = infoDialog.findViewById(R.id.topic_tree_and_mods); treeAndMods.setText(topicTreeAndMods); treeAndMods.setMovementMethod(LinkMovementMethod.getInstance()); @@ -317,25 +316,25 @@ public class TopicActivity extends BaseActivity { lastPage.setEnabled(enabled); } - private void paginationEnabledExcept(boolean enabled, View exception) { + private void paginationDisable(View exception) { if (exception == firstPage) { - previousPage.setEnabled(enabled); - nextPage.setEnabled(enabled); - lastPage.setEnabled(enabled); + previousPage.setEnabled(false); + nextPage.setEnabled(false); + lastPage.setEnabled(false); } else if (exception == previousPage) { - firstPage.setEnabled(enabled); - nextPage.setEnabled(enabled); - lastPage.setEnabled(enabled); + firstPage.setEnabled(false); + nextPage.setEnabled(false); + lastPage.setEnabled(false); } else if (exception == nextPage) { - firstPage.setEnabled(enabled); - previousPage.setEnabled(enabled); - lastPage.setEnabled(enabled); + firstPage.setEnabled(false); + previousPage.setEnabled(false); + lastPage.setEnabled(false); } else if (exception == lastPage) { - firstPage.setEnabled(enabled); - previousPage.setEnabled(enabled); - nextPage.setEnabled(enabled); + firstPage.setEnabled(false); + previousPage.setEnabled(false); + nextPage.setEnabled(false); } else { - paginationEnabled(enabled); + paginationEnabled(false); } } @@ -356,7 +355,7 @@ public class TopicActivity extends BaseActivity { increment.setOnLongClickListener( new View.OnLongClickListener() { public boolean onLongClick(View arg0) { - paginationEnabledExcept(false, arg0); + paginationDisable(arg0); autoIncrement = true; repeatUpdateHandler.postDelayed(new RepetitiveUpdater(step), INITIAL_DELAY); return false; @@ -404,7 +403,7 @@ public class TopicActivity extends BaseActivity { decrement.setOnLongClickListener( new View.OnLongClickListener() { public boolean onLongClick(View arg0) { - paginationEnabledExcept(false, arg0); + paginationDisable(arg0); autoDecrement = true; repeatUpdateHandler.postDelayed(new RepetitiveUpdater(step), INITIAL_DELAY); return false; diff --git a/app/src/main/java/gr/thmmy/mthmmy/base/BaseActivity.java b/app/src/main/java/gr/thmmy/mthmmy/base/BaseActivity.java index f844573d..6a837038 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/base/BaseActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/base/BaseActivity.java @@ -138,10 +138,8 @@ public abstract class BaseActivity extends AppCompatActivity { private AccountHeader accountHeader; private ProfileDrawerItem profileDrawerItem; - private PrimaryDrawerItem homeItem, downloadsItem, bookmarksItem, loginLogoutItem, aboutItem; - private IconicsDrawable homeIcon, homeIconSelected, downloadsIcon, downloadsIconSelected, - bookmarksIcon, bookmarksIconSelected, loginIcon, logoutIcon, aboutIcon, - aboutIconSelected; + private PrimaryDrawerItem downloadsItem, loginLogoutItem; + private IconicsDrawable loginIcon, logoutIcon; /** * Call only after initializing Toolbar @@ -151,6 +149,11 @@ public abstract class BaseActivity extends AppCompatActivity { final int selectedPrimaryColor = ContextCompat.getColor(this, R.color.primary_dark); final int selectedSecondaryColor = ContextCompat.getColor(this, R.color.accent); + PrimaryDrawerItem homeItem, bookmarksItem, aboutItem; + IconicsDrawable homeIcon, homeIconSelected, downloadsIcon, downloadsIconSelected, + bookmarksIcon, bookmarksIconSelected, aboutIcon, + aboutIconSelected; + //Drawer Icons homeIcon = new IconicsDrawable(this) .icon(FontAwesome.Icon.faw_home) diff --git a/app/src/main/java/gr/thmmy/mthmmy/base/BaseFragment.java b/app/src/main/java/gr/thmmy/mthmmy/base/BaseFragment.java index 0f3487d9..d6f69297 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/base/BaseFragment.java +++ b/app/src/main/java/gr/thmmy/mthmmy/base/BaseFragment.java @@ -13,15 +13,12 @@ public abstract class BaseFragment extends Fragment { protected FragmentInteractionListener fragmentInteractionListener; - private String TAG; - private int sectionNumber; protected static OkHttpClient client; @Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); - TAG = getArguments().getString(ARG_TAG); - sectionNumber = getArguments().getInt(ARG_SECTION_NUMBER); + //int sectionNumber = getArguments().getInt(ARG_SECTION_NUMBER); if (client == null) client = BaseApplication.getInstance().getClient(); //must check every time - e.g. // becomes null when app restarts after crash diff --git a/app/src/main/java/gr/thmmy/mthmmy/utils/CustomLinearLayoutManager.java b/app/src/main/java/gr/thmmy/mthmmy/utils/CustomLinearLayoutManager.java index cc03225c..52a5302e 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/utils/CustomLinearLayoutManager.java +++ b/app/src/main/java/gr/thmmy/mthmmy/utils/CustomLinearLayoutManager.java @@ -3,12 +3,11 @@ package gr.thmmy.mthmmy.utils; import android.content.Context; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; -import android.util.Log; import timber.log.Timber; public class CustomLinearLayoutManager extends LinearLayoutManager { - private String pageUrl; + private final String pageUrl; public CustomLinearLayoutManager(Context context, String pageUrl) { super(context); @@ -21,8 +20,6 @@ public class CustomLinearLayoutManager extends LinearLayoutManager { super.onLayoutChildren(recycler, state); } catch (IndexOutOfBoundsException e) { Timber.wtf(e, "Inconsistency detected: topic_requested = \"" + pageUrl + "\""); - Log.d("CustomLinearLayoutMan", "Inconsistency detected: topic_requested = \"" - + pageUrl + "\"", e); } } diff --git a/app/src/main/java/gr/thmmy/mthmmy/utils/ScrollAwareFABBehavior.java b/app/src/main/java/gr/thmmy/mthmmy/utils/ScrollAwareFABBehavior.java index f49fe28d..0d336ae3 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/utils/ScrollAwareFABBehavior.java +++ b/app/src/main/java/gr/thmmy/mthmmy/utils/ScrollAwareFABBehavior.java @@ -1,6 +1,7 @@ package gr.thmmy.mthmmy.utils; import android.content.Context; +import android.support.annotation.NonNull; import android.support.design.widget.CoordinatorLayout; import android.support.design.widget.FloatingActionButton; import android.support.v4.view.ViewCompat; @@ -11,27 +12,28 @@ import android.view.View; * Extends FloatingActionButton's behavior so the button will hide when scrolling down and show * otherwise. */ -@SuppressWarnings("WeakerAccess") +@SuppressWarnings("unused") public class ScrollAwareFABBehavior extends CoordinatorLayout.Behavior { - String TAG = "ScrollAwareFABBehavior"; - @SuppressWarnings("UnusedParameters") public ScrollAwareFABBehavior(Context context, AttributeSet attrs) { super(); } @Override - public boolean onStartNestedScroll(final CoordinatorLayout coordinatorLayout, final FloatingActionButton child, - final View directTargetChild, final View target, final int nestedScrollAxes) { + public boolean onStartNestedScroll(@NonNull final CoordinatorLayout coordinatorLayout, + @NonNull final FloatingActionButton child, + @NonNull final View directTargetChild, @NonNull final View target, + final int nestedScrollAxes, int type) { return nestedScrollAxes == ViewCompat.SCROLL_AXIS_VERTICAL; } @Override - public void onNestedScroll(final CoordinatorLayout coordinatorLayout, - final FloatingActionButton child, - final View target, final int dxConsumed, final int dyConsumed, - final int dxUnconsumed, final int dyUnconsumed) { - super.onNestedScroll(coordinatorLayout, child, target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed); + public void onNestedScroll(@NonNull final CoordinatorLayout coordinatorLayout, + @NonNull final FloatingActionButton child, + @NonNull final View target, final int dxConsumed, final int dyConsumed, + final int dxUnconsumed, final int dyUnconsumed, int type) { + super.onNestedScroll(coordinatorLayout, child, target, dxConsumed, dyConsumed, dxUnconsumed, + dyUnconsumed, type); if ((dyConsumed > 0 || (!target.canScrollVertically(-1) && dyConsumed == 0 && dyUnconsumed < 40)) && child.getVisibility() == View.VISIBLE) { child.hide(new FloatingActionButton.OnVisibilityChangedListener() { diff --git a/app/src/main/java/gr/thmmy/mthmmy/utils/ScrollAwareLinearBehavior.java b/app/src/main/java/gr/thmmy/mthmmy/utils/ScrollAwareLinearBehavior.java index 834cbe34..57166700 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/utils/ScrollAwareLinearBehavior.java +++ b/app/src/main/java/gr/thmmy/mthmmy/utils/ScrollAwareLinearBehavior.java @@ -2,6 +2,7 @@ package gr.thmmy.mthmmy.utils; import android.animation.Animator; import android.content.Context; +import android.support.annotation.NonNull; import android.support.design.widget.CoordinatorLayout; import android.support.v4.view.ViewCompat; import android.support.v4.view.animation.FastOutSlowInInterpolator; @@ -14,7 +15,7 @@ import android.view.ViewPropertyAnimator; *

When a nested ScrollView is scrolled down, the view will disappear. * When the ScrollView is scrolled back up, the view will reappear.

*/ -@SuppressWarnings("WeakerAccess") +@SuppressWarnings("unused") public class ScrollAwareLinearBehavior extends CoordinatorLayout.Behavior { private static final int ANIMATION_DURATION = 100; @@ -23,15 +24,19 @@ public class ScrollAwareLinearBehavior extends CoordinatorLayout.Behavior } @Override - public boolean onStartNestedScroll(CoordinatorLayout coordinatorLayout, View child, View directTargetChild, View target, int nestedScrollAxes) { + public boolean onStartNestedScroll(@NonNull CoordinatorLayout coordinatorLayout, + @NonNull View child, @NonNull View directTargetChild, + @NonNull View target, int nestedScrollAxes, int type) { return (nestedScrollAxes & ViewCompat.SCROLL_AXIS_VERTICAL) != 0; } @Override - public void onNestedScroll(CoordinatorLayout coordinatorLayout, View bottomNavBar, View target, + public void onNestedScroll(@NonNull CoordinatorLayout coordinatorLayout, + @NonNull View bottomNavBar, @NonNull View target, int dxConsumed, int dyConsumed, - int dxUnconsumed, int dyUnconsumed) { - super.onNestedScroll(coordinatorLayout, bottomNavBar, target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed); + int dxUnconsumed, int dyUnconsumed, int type) { + super.onNestedScroll(coordinatorLayout, bottomNavBar, target, dxConsumed, dyConsumed, + dxUnconsumed, dyUnconsumed, type); if ((dyConsumed > 0 || (!target.canScrollVertically(-1) && dyConsumed == 0 && dyUnconsumed < 40)) && bottomNavBar.getVisibility() == View.VISIBLE) { hide(bottomNavBar); diff --git a/app/src/main/res/layout/dialog_topic_info.xml b/app/src/main/res/layout/dialog_topic_info.xml index 47b8ec31..047c0a23 100644 --- a/app/src/main/res/layout/dialog_topic_info.xml +++ b/app/src/main/res/layout/dialog_topic_info.xml @@ -8,6 +8,7 @@ Date: Sun, 30 Jul 2017 18:17:12 +0300 Subject: [PATCH 5/6] Downloads fixes --- .../main/java/gr/thmmy/mthmmy/receiver/Receiver.java | 12 ++++++------ .../gr/thmmy/mthmmy/services/DownloadService.java | 8 ++++---- app/src/main/res/drawable/ic_file_download.xml | 9 --------- 3 files changed, 10 insertions(+), 19 deletions(-) delete mode 100644 app/src/main/res/drawable/ic_file_download.xml diff --git a/app/src/main/java/gr/thmmy/mthmmy/receiver/Receiver.java b/app/src/main/java/gr/thmmy/mthmmy/receiver/Receiver.java index 2ef4fdd4..a36916ea 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/receiver/Receiver.java +++ b/app/src/main/java/gr/thmmy/mthmmy/receiver/Receiver.java @@ -29,8 +29,7 @@ import static gr.thmmy.mthmmy.services.DownloadService.STARTED; public class Receiver extends BroadcastReceiver { - public Receiver() { - } + public Receiver() {} @Override public void onReceive(Context context, Intent intent) { @@ -48,11 +47,11 @@ public class Receiver extends BroadcastReceiver { builder.setContentTitle(title) .setContentText(text) .setTicker(ticker) - .setAutoCancel(true) - .setSmallIcon(R.drawable.ic_file_download); + .setAutoCancel(true); if (state.equals(STARTED)) - builder.setOngoing(true); + builder.setOngoing(true) + .setSmallIcon(android.R.drawable.stat_sys_download); else if (state.equals(COMPLETED)) { String fileName = extras.getString(EXTRA_FILE_NAME, "NONE"); @@ -68,7 +67,8 @@ public class Receiver extends BroadcastReceiver { Intent chooser = Intent.createChooser(chooserIntent, "Open With..."); PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, chooser, PendingIntent.FLAG_CANCEL_CURRENT); - builder.setContentIntent(pendingIntent); + builder.setContentIntent(pendingIntent) + .setSmallIcon(android.R.drawable.stat_sys_download_done); } else Timber.w("File doesn't exist."); diff --git a/app/src/main/java/gr/thmmy/mthmmy/services/DownloadService.java b/app/src/main/java/gr/thmmy/mthmmy/services/DownloadService.java index 4e22c7b1..c14387f1 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/services/DownloadService.java +++ b/app/src/main/java/gr/thmmy/mthmmy/services/DownloadService.java @@ -106,9 +106,9 @@ public class DownloadService extends IntentService { Request request = new Request.Builder().url(downloadLink).build(); Response response = client.newCall(request).execute(); - String contentType = response.headers("Content-Type").toString(); //check if link provides a binary file - if (contentType.equals("[application/octet-stream]")) { - fileName = response.headers("Content-Disposition").toString().split("\"")[1]; + String contentDisposition = response.headers("Content-Disposition").toString(); //check if link provides an attachment + if (contentDisposition.contains("attachment")){ + fileName = contentDisposition.split("\"")[1]; File dirPath = new File(SAVE_DIR); if (!dirPath.isDirectory()) { @@ -150,7 +150,7 @@ public class DownloadService extends IntentService { Timber.i("Download OK!"); sendNotification(downloadId, COMPLETED, fileName); } else - Timber.e("Response not a binary file!"); + Timber.e("No attachment in response!"); } catch (FileNotFoundException e) { Timber.i("Download failed..."); Timber.e(e, "FileNotFound"); diff --git a/app/src/main/res/drawable/ic_file_download.xml b/app/src/main/res/drawable/ic_file_download.xml deleted file mode 100644 index 80734766..00000000 --- a/app/src/main/res/drawable/ic_file_download.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - From c66bf9fb21a3e0d7ff0005bbb69dd16b809a3b97 Mon Sep 17 00:00:00 2001 From: Ezerous Date: Mon, 31 Jul 2017 10:10:16 +0300 Subject: [PATCH 6/6] Up version --- VERSION | 2 +- app/build.gradle | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/VERSION b/VERSION index f0bb29e7..3a3cd8cc 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.3.0 +1.3.1 diff --git a/app/build.gradle b/app/build.gradle index 69de9530..571dd5b2 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -9,8 +9,8 @@ android { applicationId "gr.thmmy.mthmmy" minSdkVersion 19 targetSdkVersion 26 - versionCode 8 - versionName "1.3.0" + versionCode 9 + versionName "1.3.1" archivesBaseName = "mTHMMY-v$versionName" }