Skip to content

Commit

Permalink
评论页面升级完成
Browse files Browse the repository at this point in the history
  • Loading branch information
CeuiLiSA authored and CeuiLiSA committed Sep 24, 2019
1 parent ab39416 commit b7f7020
Show file tree
Hide file tree
Showing 30 changed files with 261 additions and 249 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ android {
applicationId "ceui.lisa"
minSdkVersion 21
targetSdkVersion 28
versionCode 31
versionName "1.0.31"
versionCode 32
versionName "1.0.32"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

manifestPlaceholders = [
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/java/ceui/lisa/adapters/IllustAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ public IllustAdapter(List<IllustsBean> list, Context context,
mRecyclerView = recyclerView;
mRefreshLayout = refreshLayout;
mManager = (GridScrollChangeManager) mRecyclerView.getLayoutManager();

imageSize = (mContext.getResources().getDisplayMetrics().widthPixels -
mContext.getResources().getDimensionPixelSize(R.dimen.four_dp)) / 2;
}

@NonNull
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/java/ceui/lisa/fragments/BaseListFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public abstract class BaseListFragment<Response extends ListShow<ListItem>,
protected String nextUrl = "";
protected ImageView noData;

public BaseListFragment(){
public BaseListFragment() {
Common.showLog(className + "new instance !!");
}

Expand Down Expand Up @@ -136,7 +136,7 @@ public void onClick(View v) {
initRecyclerView();
if (className.equals("FragmentRecmdIllust ")) {
mRefreshLayout.setRefreshHeader(new ClassicsHeader(mContext));
}else {
} else {
mRefreshLayout.setRefreshHeader(new DeliveryHeader(mContext));
}
mRefreshLayout.setOnRefreshListener(layout -> getFirstData());
Expand Down Expand Up @@ -299,7 +299,7 @@ public void netError() {

});
}
}else {
} else {
mRefreshLayout.setEnableLoadMore(false);
mRefreshLayout.finishLoadMore(false);
mRefreshLayout.setRefreshFooter(new FalsifyFooter(mContext));
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/ceui/lisa/fragments/Ext.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ package ceui.lisa.fragments
import android.widget.TextView
import ceui.lisa.utils.Common

fun TextView.fuck(){
fun TextView.fuck() {
Common.showLog("hahhahahha")
}
16 changes: 8 additions & 8 deletions app/src/main/java/ceui/lisa/fragments/FragmentA.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,21 +61,21 @@ public boolean onMenuItemClick(MenuItem item) {
BaseItemAnimator baseItemAnimator = null;
if (item.getItemId() == R.id.action_1) {
baseItemAnimator = new FadeInAnimator();
}else if (item.getItemId() == R.id.action_2) {
} else if (item.getItemId() == R.id.action_2) {
baseItemAnimator = new FadeInDownAnimator();
}else if (item.getItemId() == R.id.action_3) {
} else if (item.getItemId() == R.id.action_3) {
baseItemAnimator = new FadeInLeftAnimator();
}else if (item.getItemId() == R.id.action_4) {
} else if (item.getItemId() == R.id.action_4) {
baseItemAnimator = new FlipInBottomXAnimator();
}else if (item.getItemId() == R.id.action_5) {
} else if (item.getItemId() == R.id.action_5) {
baseItemAnimator = new FlipInLeftYAnimator();
}else if (item.getItemId() == R.id.action_6) {
} else if (item.getItemId() == R.id.action_6) {
baseItemAnimator = new LandingAnimator();
}else if (item.getItemId() == R.id.action_7) {
} else if (item.getItemId() == R.id.action_7) {
baseItemAnimator = new ScaleInAnimator();
}else if (item.getItemId() == R.id.action_8) {
} else if (item.getItemId() == R.id.action_8) {
baseItemAnimator = new ScaleInBottomAnimator();
}else if (item.getItemId() == R.id.action_9) {
} else if (item.getItemId() == R.id.action_9) {
baseItemAnimator = new SlideInDownAnimator();
}
baseItemAnimator.setAddDuration(animateDuration);
Expand Down
21 changes: 7 additions & 14 deletions app/src/main/java/ceui/lisa/fragments/FragmentC.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,25 @@

import android.content.DialogInterface;
import android.content.Intent;
import android.view.View;

import androidx.appcompat.app.AlertDialog;
import androidx.recyclerview.widget.LinearLayoutManager;

import ceui.lisa.R;
import ceui.lisa.activities.Shaft;
import ceui.lisa.activities.UserDetailActivity;
import ceui.lisa.adapters.CAdapter;
import ceui.lisa.databinding.RecyCommentListBinding;
import ceui.lisa.http.Retro;
import ceui.lisa.interfaces.OnItemClickListener;
import ceui.lisa.model.CommentsBean;
import ceui.lisa.model.IllustCommentsResponse;
import ceui.lisa.utils.Common;
import ceui.lisa.utils.Local;
import io.reactivex.Observable;

import static ceui.lisa.activities.Shaft.sUserModel;
import static ceui.lisa.fragments.FragmentFilter.ALL_SIZE;
import static ceui.lisa.fragments.FragmentFilter.ALL_SIZE_VALUE;

public class FragmentC extends FragmentList<IllustCommentsResponse, CommentsBean, RecyCommentListBinding> {

private int illustID;
public static final String[] OPTIONS = new String[]{"回复评论", "复制评论"};
private int illustID;

public static FragmentC newInstance(int id) {
FragmentC comment = new FragmentC();
Expand Down Expand Up @@ -59,15 +52,15 @@ public void initAdapter() {
builder.setItems(OPTIONS, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if(which == 0){
if(getParentFragment() instanceof FragmentComment){
if (which == 0) {
if (getParentFragment() instanceof FragmentComment) {
((FragmentComment) getParentFragment()).baseBind.inputBox.setHint(
"回复" + allItems.get(position).getUser().getName()
);
((FragmentComment) getParentFragment()).parentCommentID =
allItems.get(position).getId();
}
} else if(which == 1){
} else if (which == 1) {
Common.copy(mContext, allItems.get(position).getComment());
}
}
Expand All @@ -83,15 +76,15 @@ public void onClick(DialogInterface dialog, int which) {
builder.setItems(OPTIONS, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if(which == 0){
if(getParentFragment() instanceof FragmentComment){
if (which == 0) {
if (getParentFragment() instanceof FragmentComment) {
((FragmentComment) getParentFragment()).baseBind.inputBox.setHint(
"回复" + allItems.get(position).getParent_comment().getUser().getName()
);
((FragmentComment) getParentFragment()).parentCommentID =
allItems.get(position).getParent_comment().getId();
}
} else if(which == 1){
} else if (which == 1) {
Common.copy(mContext, allItems.get(position).getParent_comment().getComment());
}
}
Expand Down
30 changes: 0 additions & 30 deletions app/src/main/java/ceui/lisa/fragments/FragmentCenter.java
Original file line number Diff line number Diff line change
@@ -1,50 +1,20 @@
package ceui.lisa.fragments;

import android.content.Intent;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.fragment.app.FragmentTransaction;
import androidx.recyclerview.widget.RecyclerView;

import com.mancj.materialsearchbar.MaterialSearchBar;
import com.mancj.materialsearchbar.adapter.SuggestionsAdapter;
import com.scwang.smartrefresh.layout.api.RefreshLayout;
import com.scwang.smartrefresh.layout.footer.FalsifyFooter;
import com.scwang.smartrefresh.layout.header.FalsifyHeader;

import java.util.List;
import java.util.concurrent.TimeUnit;

import ceui.lisa.R;
import ceui.lisa.activities.RankActivity;
import ceui.lisa.activities.Shaft;
import ceui.lisa.activities.TemplateFragmentActivity;
import ceui.lisa.activities.UserDetailActivity;
import ceui.lisa.http.ErrorCtrl;
import ceui.lisa.http.Retro;
import ceui.lisa.model.TrendingtagResponse;
import ceui.lisa.utils.Common;
import ceui.lisa.utils.PixivOperate;
import ceui.lisa.utils.optional.Consumer;
import ceui.lisa.utils.optional.Optional;
import io.reactivex.Observable;
import io.reactivex.ObservableEmitter;
import io.reactivex.ObservableOnSubscribe;
import io.reactivex.Observer;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;

import static ceui.lisa.activities.Shaft.sUserModel;
import static ceui.lisa.utils.Common.isNumeric;

public class FragmentCenter extends BaseFragment {

Expand Down
67 changes: 59 additions & 8 deletions app/src/main/java/ceui/lisa/fragments/FragmentComment.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,24 @@
import android.view.View;

import androidx.fragment.app.FragmentTransaction;
import androidx.recyclerview.widget.LinearLayoutManager;

import ceui.lisa.R;
import ceui.lisa.adapters.CommentAdapter;
import ceui.lisa.databinding.FragmentCommentBinding;
import ceui.lisa.http.NullCtrl;
import ceui.lisa.http.Retro;
import ceui.lisa.model.CommentsBean;
import ceui.lisa.model.IllustCommentsResponse;
import io.reactivex.Observable;
import ceui.lisa.model.CommentHolder;
import ceui.lisa.utils.Common;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;

import static ceui.lisa.activities.Shaft.sUserModel;

public class FragmentComment extends BaseBindFragment<FragmentCommentBinding> {

public int parentCommentID;
private int illustID;
private String title;
public int parentCommentID;

public static FragmentComment newInstance(int id, String title) {
FragmentComment comment = new FragmentComment();
Expand All @@ -35,7 +36,13 @@ void initLayout() {

@Override
void initData() {
baseBind.toolbar.setTitle(title);
baseBind.toolbar.setTitle(title + "的评论");
baseBind.toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mActivity.finish();
}
});
FragmentC fragmentC = FragmentC.newInstance(illustID);
FragmentTransaction fragmentTransaction = getChildFragmentManager().beginTransaction();
fragmentTransaction
Expand All @@ -45,7 +52,51 @@ void initData() {
baseBind.post.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO: 2019-09-24
if (baseBind.inputBox.getText().toString().length() == 0) {
Common.showToast("请输入评论内容");
return;
}

Retro.getAppApi().postComment(sUserModel.getResponse().getAccess_token(), illustID,
baseBind.inputBox.getText().toString(), parentCommentID)
.subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new NullCtrl<CommentHolder>() {
@Override
public void onSubscribe(Disposable d) {
Common.hideKeyboard(mActivity);
baseBind.inputBox.setHint("请输入评论内容");
baseBind.inputBox.setText("");
baseBind.progress.setVisibility(View.VISIBLE);
}

@Override
public void success(CommentHolder commentHolder) {
fragmentC.allItems.add(0, commentHolder.getComment());
fragmentC.mAdapter.notifyItemInserted(0);
fragmentC.baseBind.recyclerView.scrollToPosition(0);
//fragmentC.baseBind.refreshLayout.autoRefresh();
}

@Override
public void must(boolean isSuccess) {
baseBind.progress.setVisibility(View.GONE);
}
});
}
});
baseBind.clear.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (baseBind.inputBox.getText().toString().length() != 0) {
baseBind.inputBox.setText("");
return;
}
if (parentCommentID != 0) {
baseBind.inputBox.setHint("留下你的评论吧");
parentCommentID = 0;
return;
}
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ void initLayout() {
@Override
View initView(View v) {
mImageView = v.findViewById(R.id.illust_image);
if(Shaft.sSettings.isFirstImageSize()){
if (Shaft.sSettings.isFirstImageSize()) {
Glide.with(mContext)
//.load(GlideUtil.getOriginal(mIllustsBean, index))
.load(GlideUtil.getOriginal(mIllustsBean, index))
.transition(withCrossFade())
.into(mImageView);
}else {
} else {
Glide.with(mContext)
//.load(GlideUtil.getOriginal(mIllustsBean, index))
.load(GlideUtil.getLargeImage(mIllustsBean, index))
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/ceui/lisa/fragments/FragmentLicense.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import ceui.lisa.R;
import ceui.lisa.databinding.FragmentLicenseBinding;

public class FragmentLicense extends BaseBindFragment<FragmentLicenseBinding>{
public class FragmentLicense extends BaseBindFragment<FragmentLicenseBinding> {

@Override
void initLayout() {
Expand All @@ -27,6 +27,6 @@ public void onClick(View v) {
new LibsBuilder()
.withAboutAppName("Shaft")
.withLibraryModification("aboutlibraries",
Libs.LibraryFields.LIBRARY_OPEN_SOURCE, "_AboutLibraries").supportFragment()).commit();
Libs.LibraryFields.LIBRARY_OPEN_SOURCE, "_AboutLibraries").supportFragment()).commit();
}
}
Loading

0 comments on commit b7f7020

Please sign in to comment.