Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
FranckRJ committed Jan 19, 2020
2 parents 033f772 + eaa7aa8 commit bad949c
Show file tree
Hide file tree
Showing 260 changed files with 196 additions and 106 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
/.idea/vcs.xml
/.idea/.name
.DS_Store
/build
/captures
Expand Down
16 changes: 8 additions & 8 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ android {
applicationId "com.franckrj.respawnirc"
minSdkVersion 21
targetSdkVersion 29
versionCode 2_000_2_001
versionName "2.0.1"
versionCode 2_001_2_000
versionName "2.1"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
resConfigs "fr"
}
Expand Down Expand Up @@ -55,16 +55,16 @@ dependencies {
implementation 'androidx.fragment:fragment:1.1.0'
implementation 'androidx.fragment:fragment-ktx:1.1.0'
implementation 'androidx.gridlayout:gridlayout:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'com.github.bumptech.glide:annotations:4.10.0'
implementation 'com.github.bumptech.glide:glide:4.10.0'
implementation 'com.github.bumptech.glide:okhttp3-integration:4.10.0'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'com.github.bumptech.glide:annotations:4.11.0'
implementation 'com.github.bumptech.glide:glide:4.11.0'
implementation 'com.github.bumptech.glide:okhttp3-integration:4.11.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'com.squareup.okhttp3:okhttp:4.2.2'
implementation 'com.squareup.okhttp3:okhttp:4.3.1'
implementation 'com.takisoft.preferencex:preferencex:1.0.0'
implementation 'com.takisoft.preferencex:preferencex-colorpicker:1.0.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.2'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.2'
kapt 'com.github.bumptech.glide:compiler:4.10.0'
kapt 'com.github.bumptech.glide:compiler:4.11.0'
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;

import androidx.annotation.NonNull;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import androidx.cardview.widget.CardView;
import android.view.View;
Expand Down Expand Up @@ -38,6 +40,8 @@ public class ShowForumInfosActivity extends AbsHomeIsBackActivity {
private LinearLayout mainLayout = null;
private TextView forumNameText = null;
private TextView numberOfConnectedView = null;
private CardView mainForumCardView = null;
private Button mainForumButton = null;
private CardView subforumsCardView = null;
private LinearLayout layoutListOfSubforums = null;
private TextView listOfModeratorsText = null;
Expand All @@ -46,85 +50,64 @@ public class ShowForumInfosActivity extends AbsHomeIsBackActivity {
private DownloadForumInfos currentTaskForDownload = null;
private ForumInfos infosForForum = null;

private final View.OnClickListener subforumButtonClickedListener = new View.OnClickListener() {
@Override
public void onClick(View button) {
if (button.getTag() != null && button.getTag() instanceof String) {
Intent newShowForumIntent = new Intent(ShowForumInfosActivity.this, ShowForumActivity.class);
newShowForumIntent.putExtra(ShowForumActivity.EXTRA_NEW_LINK, (String) button.getTag());
newShowForumIntent.putExtra(ShowForumActivity.EXTRA_IS_FIRST_ACTIVITY, false);
startActivity(newShowForumIntent);
}
private final View.OnClickListener forumButtonClickedListener = button -> {
if (button.getTag() != null && button.getTag() instanceof String) {
Intent newShowForumIntent = new Intent(ShowForumInfosActivity.this, ShowForumActivity.class);
newShowForumIntent.putExtra(ShowForumActivity.EXTRA_NEW_LINK, (String) button.getTag());
newShowForumIntent.putExtra(ShowForumActivity.EXTRA_IS_FIRST_ACTIVITY, false);
startActivity(newShowForumIntent);
}
};

private final View.OnClickListener noMissTopicButtonClickedListener = new View.OnClickListener() {
@Override
public void onClick(View button) {
if (button.getTag() != null && button.getTag() instanceof String) {
noMissTopicButtonClicked((String) button.getTag(), false);
}
private final View.OnClickListener noMissTopicButtonClickedListener = button -> {
if (button.getTag() != null && button.getTag() instanceof String) {
noMissTopicButtonClicked((String) button.getTag(), false);
}
};

private final View.OnLongClickListener noMissTopicButtonLongClickedListener = new View.OnLongClickListener() {
@Override
public boolean onLongClick(View button) {
if (button.getTag() != null && button.getTag() instanceof String) {
noMissTopicButtonClicked((String) button.getTag(), true);
}
return true;
private final View.OnLongClickListener noMissTopicButtonLongClickedListener = button -> {
if (button.getTag() != null && button.getTag() instanceof String) {
noMissTopicButtonClicked((String) button.getTag(), true);
}
return true;
};

private final View.OnClickListener contactModeratorsButtonClickedListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
if (infosForForum != null && !infosForForum.listOfModeratorsString.isEmpty()) {
Utils.openLinkInInternalBrowser("http://www.jeuxvideo.com/messages-prives/nouveau.php?all_dest=" + infosForForum.listOfModeratorsString.replace(", ", ";"), ShowForumInfosActivity.this);
} else {
Toast.makeText(ShowForumInfosActivity.this, R.string.errorDuringContactModerators, Toast.LENGTH_SHORT).show();
}
private final View.OnClickListener contactModeratorsButtonClickedListener = view -> {
if (infosForForum != null && !infosForForum.listOfModeratorsString.isEmpty()) {
Utils.openLinkInInternalBrowser("http://www.jeuxvideo.com/messages-prives/nouveau.php?all_dest=" + infosForForum.listOfModeratorsString.replace(", ", ";"), ShowForumInfosActivity.this);
} else {
Toast.makeText(ShowForumInfosActivity.this, R.string.errorDuringContactModerators, Toast.LENGTH_SHORT).show();
}
};

private final View.OnClickListener showForumRulesButtonClickedListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
if (getIntent() != null && getIntent().getStringExtra(EXTRA_FORUM_LINK) != null) {
PrefsManager.LinkType linkTypeForInternalBrowser = new PrefsManager.LinkType(PrefsManager.LinkType.NO_LINKS);
String forumLink = getIntent().getStringExtra(EXTRA_FORUM_LINK);
private final View.OnClickListener showForumRulesButtonClickedListener = view -> {
if (getIntent() != null && getIntent().getStringExtra(EXTRA_FORUM_LINK) != null) {
PrefsManager.LinkType linkTypeForInternalBrowser = new PrefsManager.LinkType(PrefsManager.LinkType.NO_LINKS);
String forumLink = getIntent().getStringExtra(EXTRA_FORUM_LINK);

linkTypeForInternalBrowser.setTypeFromString(PrefsManager.getString(PrefsManager.StringPref.Names.LINK_TYPE_FOR_INTERNAL_BROWSER));
Utils.openCorrespondingBrowser(linkTypeForInternalBrowser, "http://www.jeuxvideo.com/forums/" + JVCParser.getForumNameOfThisForum(forumLink) + "/regles-forum/" + JVCParser.getForumIdOfThisForum(forumLink), ShowForumInfosActivity.this);
} else {
Toast.makeText(ShowForumInfosActivity.this, R.string.errorDuringShowRules, Toast.LENGTH_SHORT).show();
}
linkTypeForInternalBrowser.setTypeFromString(PrefsManager.getString(PrefsManager.StringPref.Names.LINK_TYPE_FOR_INTERNAL_BROWSER));
Utils.openCorrespondingBrowser(linkTypeForInternalBrowser, "http://www.jeuxvideo.com/forums/" + JVCParser.getForumNameOfThisForum(forumLink) + "/regles-forum/" + JVCParser.getForumIdOfThisForum(forumLink), ShowForumInfosActivity.this);
} else {
Toast.makeText(ShowForumInfosActivity.this, R.string.errorDuringShowRules, Toast.LENGTH_SHORT).show();
}
};

private final AbsWebRequestAsyncTask.RequestIsStarted requestIsStartedListener = new AbsWebRequestAsyncTask.RequestIsStarted() {
@Override
public void onRequestIsStarted() {
backgroundErrorText.setVisibility(View.GONE);
swipeRefresh.setRefreshing(true);
}
private final AbsWebRequestAsyncTask.RequestIsStarted requestIsStartedListener = () -> {
backgroundErrorText.setVisibility(View.GONE);
swipeRefresh.setRefreshing(true);
};

private final AbsWebRequestAsyncTask.RequestIsFinished<ForumInfos> downloadInfosIsFinishedListener = new AbsWebRequestAsyncTask.RequestIsFinished<ForumInfos>() {
@Override
public void onRequestIsFinished(ForumInfos newInfos) {
swipeRefresh.setRefreshing(false);

if (newInfos != null) {
infosForForum = newInfos;
updateDisplayedInfos();
} else {
backgroundErrorText.setVisibility(View.VISIBLE);
}
private final AbsWebRequestAsyncTask.RequestIsFinished<ForumInfos> downloadInfosIsFinishedListener = newInfos -> {
swipeRefresh.setRefreshing(false);

currentTaskForDownload = null;
if (newInfos != null) {
infosForForum = newInfos;
updateDisplayedInfos();
} else {
backgroundErrorText.setVisibility(View.VISIBLE);
}

currentTaskForDownload = null;
};

private void noMissTopicButtonClicked(String linkClicked, boolean isFromLongClick) {
Expand All @@ -146,14 +129,22 @@ private void updateDisplayedInfos() {
} else {
numberOfConnectedView.setText(R.string.errorNumberConnected);
}
if (infosForForum.mainForum != null) {
mainForumCardView.setVisibility(View.VISIBLE);
mainForumButton.setText(Undeprecator.htmlFromHtml(infosForForum.mainForum.name));
mainForumButton.setTag(infosForForum.mainForum.link);
mainForumButton.setOnClickListener(forumButtonClickedListener);
} else {
mainForumCardView.setVisibility(View.GONE);
}
if (!infosForForum.listOfSubforums.isEmpty()) {
subforumsCardView.setVisibility(View.VISIBLE);
for (JVCParser.NameAndLink nameAndLink : infosForForum.listOfSubforums) {
Button newSubforumButton = (Button) getLayoutInflater().inflate(R.layout.button_subforum, layoutListOfSubforums, false);

newSubforumButton.setText(Undeprecator.htmlFromHtml(nameAndLink.name));
newSubforumButton.setTag(nameAndLink.link);
newSubforumButton.setOnClickListener(subforumButtonClickedListener);
newSubforumButton.setOnClickListener(forumButtonClickedListener);

layoutListOfSubforums.addView(newSubforumButton);
}
Expand Down Expand Up @@ -206,6 +197,8 @@ public void onCreate(final Bundle savedInstanceState) {
mainLayout = findViewById(R.id.main_layout_showforuminfos);
forumNameText = findViewById(R.id.foruminfos_title_showforuminfos);
numberOfConnectedView = findViewById(R.id.text_numberofconnected_showforuminfos);
mainForumCardView = findViewById(R.id.mainforum_card_showforuminfos);
mainForumButton = findViewById(R.id.mainforum_button_showforuminfos);
subforumsCardView = findViewById(R.id.subforum_card_showforuminfos);
layoutListOfSubforums = findViewById(R.id.subforum_list_showforuminfos);
listOfModeratorsText = findViewById(R.id.listofmoderators_text_showforuminfos);
Expand All @@ -224,12 +217,7 @@ public void onCreate(final Bundle savedInstanceState) {
infosForForum = savedInstanceState.getParcelable(SAVE_FORUM_INFOS);
updateDisplayedInfos();

mainScrollView.post(new Runnable() {
@Override
public void run() {
mainScrollView.scrollTo(0, savedInstanceState.getInt(SAVE_SCROLL_POSITION, 0));
}
});
mainScrollView.post(() -> mainScrollView.scrollTo(0, savedInstanceState.getInt(SAVE_SCROLL_POSITION, 0)));
}
}

Expand Down Expand Up @@ -260,7 +248,7 @@ public void onPause() {
}

@Override
public void onSaveInstanceState(Bundle outState) {
public void onSaveInstanceState(@NonNull Bundle outState) {
super.onSaveInstanceState(outState);
outState.putParcelable(SAVE_FORUM_INFOS, infosForForum);
outState.putInt(SAVE_SCROLL_POSITION, mainScrollView.getScrollY());
Expand All @@ -276,6 +264,7 @@ protected ForumInfos doInBackground(String... params) {
if (source != null && !source.isEmpty()) {
ForumInfos newForumInfos = new ForumInfos();

newForumInfos.mainForum = JVCParser.getMainForumNameAndLinkInForumPage(source);
newForumInfos.forumName = JVCParser.getForumNameInForumPage(source);
newForumInfos.numberOfConnected = JVCParser.getNumberOfConnectFromPage(source);
newForumInfos.listOfSubforums = JVCParser.getListOfSubforumsInForumPage(source);
Expand All @@ -289,6 +278,7 @@ protected ForumInfos doInBackground(String... params) {
}

private static class ForumInfos implements Parcelable {
public JVCParser.NameAndLink mainForum = null;
public String forumName = "";
public String numberOfConnected = "";
public ArrayList<JVCParser.NameAndLink> listOfSubforums = new ArrayList<>();
Expand All @@ -312,6 +302,12 @@ public ForumInfos() {
}

private ForumInfos(Parcel in) {
if (in.readByte() == 1) {
mainForum = in.readParcelable(JVCParser.NameAndLink.class.getClassLoader());
} else {
mainForum = null;
}

forumName = in.readString();
numberOfConnected = in.readString();
in.readTypedList(listOfSubforums, JVCParser.NameAndLink.CREATOR);
Expand All @@ -326,6 +322,13 @@ public int describeContents() {

@Override
public void writeToParcel(Parcel out, int flags) {
if (mainForum != null) {
out.writeByte((byte)1);
out.writeParcelable(mainForum, flags);
} else {
out.writeByte((byte)0);
}

out.writeString(forumName);
out.writeString(numberOfConnected);
out.writeTypedList(listOfSubforums);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import com.franckrj.respawnirc.base.AbsWebRequestAsyncTask;
import com.franckrj.respawnirc.utils.JVCParser;
import com.franckrj.respawnirc.utils.Utils;
import com.franckrj.respawnirc.utils.WebManager;

import java.util.ArrayList;
Expand Down Expand Up @@ -139,7 +140,8 @@ protected boolean fillBaseClassInfoFromPageInfo(TopicPageInfos newPageInfos) {
boolean pageDownloadedIsAnalysable = true;

if (!newPageInfos.newUrlForTopicPage.isEmpty()) {
if (JVCParser.checkIfTopicAreSame(urlForTopicPage, newPageInfos.newUrlForTopicPage)) {
if (JVCParser.checkIfItsTopicFormatedLink(newPageInfos.newUrlForTopicPage)
&& Utils.stringsAreEquals(JVCParser.getTopicIdOfThisTopic(urlForTopicPage), JVCParser.getTopicIdOfThisTopic(newPageInfos.newUrlForTopicPage))) {
if (JVCParser.getPageNumberForThisTopicLink(urlForTopicPage).equals(JVCParser.getPageNumberForThisTopicLink(newPageInfos.newUrlForTopicPage))) {
urlForTopicPage = newPageInfos.newUrlForTopicPage;
if (listenerForTopicLinkChanged != null) {
Expand Down
Loading

0 comments on commit bad949c

Please sign in to comment.