Просмотр исходного кода

可以通过活动进入发现界面并可以返回,不再跳转主页

zengjiebin лет назад: 7
Родитель
Сommit
59d293fd4b

+ 4 - 0
app/src/main/AndroidManifest.xml

@@ -975,6 +975,10 @@
             android:name="com.sheep.gamegroup.module.game.activity.ActGameGroupOrGameDetail"
             android:theme="@style/AppActionTheme"
             android:screenOrientation="portrait" />
+        <activity
+            android:name="com.sheep.gamegroup.module.find.activity.ActFind"
+            android:theme="@style/AppActionTheme"
+            android:screenOrientation="portrait" />
     </application>
 
 </manifest>

+ 1 - 1
app/src/main/java/com/sheep/gamegroup/model/entity/WebParams.java

@@ -17,7 +17,7 @@ public class WebParams implements Serializable {
     private boolean needJsInteract = true;
     private boolean showTitle = true;
     private boolean forResult = false;
-    private boolean refreshClick = false;
+    private boolean refreshClick = true;
     private int action;
     private String tokenKey = "authorization";
     private String invitationCodeKey = "invitation_code";

+ 23 - 0
app/src/main/java/com/sheep/gamegroup/module/find/activity/ActFind.java

@@ -0,0 +1,23 @@
+package com.sheep.gamegroup.module.find.activity;
+
+import android.support.v4.app.Fragment;
+
+import com.sheep.gamegroup.absBase.BaseContainerActivity;
+import com.sheep.gamegroup.module.find.fragment.FgtFind2;
+import com.sheep.jiuyan.samllsheep.R;
+
+/**
+ * Created by realicing on 2019/1/28.
+ * realicing@sina.com
+ */
+public class ActFind extends BaseContainerActivity {
+    @Override
+    protected int getLayoutId() {
+        return R.layout.common_container_nofit;
+    }
+
+    @Override
+    protected Fragment initFragment() {
+        return new FgtFind2();
+    }
+}

+ 213 - 0
app/src/main/java/com/sheep/gamegroup/module/find/fragment/FgtFind2.java

@@ -0,0 +1,213 @@
+package com.sheep.gamegroup.module.find.fragment;
+
+import android.app.Activity;
+import android.provider.MediaStore;
+import android.support.design.widget.TabLayout;
+import android.support.v4.view.ViewPager;
+import android.view.KeyEvent;
+import android.view.View;
+import android.widget.ImageView;
+
+import com.kfzs.duanduan.utils.NumberFormatUtils;
+import com.sheep.gamegroup.model.entity.ArticleTag;
+import com.sheep.gamegroup.model.entity.BaseMessage;
+import com.sheep.gamegroup.model.util.SheepSubscriber;
+import com.sheep.gamegroup.util.CommonUtil;
+import com.sheep.gamegroup.util.DataUtil;
+import com.sheep.gamegroup.util.Jump2View;
+import com.sheep.gamegroup.util.KeyEventUtil;
+import com.sheep.gamegroup.util.ListUtil;
+import com.sheep.gamegroup.util.ViewUtil;
+import com.sheep.gamegroup.view.adapter.TitleFragmentListAdapter;
+import com.sheep.gamegroup.view.fragment.FgtArticleVideo;
+import com.sheep.gamegroup.view.fragment.FgtFindChild;
+import com.sheep.gamegroup.view.fragment.FgtWatchFocus;
+import com.sheep.jiuyan.samllsheep.R;
+import com.sheep.jiuyan.samllsheep.SheepApp;
+import com.sheep.jiuyan.samllsheep.base.BaseFragment;
+import com.sheep.jiuyan.samllsheep.utils.TitleBarUtils;
+
+import org.afinal.simplecache.ApiKey;
+
+import java.util.List;
+
+import butterknife.BindView;
+import io.reactivex.android.schedulers.AndroidSchedulers;
+import io.reactivex.schedulers.Schedulers;
+import rx.functions.Action1;
+
+import static com.sheep.gamegroup.util.UMConfigUtils.Event.FIND_TAG;
+
+/**
+ * Created by realicing on 2018/6/27.
+ * realicing@sina.com
+ * 主页--发现模块
+ */
+public class FgtFind2 extends BaseFragment {
+    private Activity activity;
+
+    @BindView(R.id.indicator)
+    TabLayout indicator;
+    @BindView(R.id.pager)
+    ViewPager pager;
+    @BindView(R.id.add_article)
+    View add_article;
+    @BindView(R.id.add_article_expand)
+    ImageView add_article_expand;
+    @BindView(R.id.add_article_iv)
+    ImageView add_article_iv;
+    @BindView(R.id.add_article_camera)
+    ImageView add_article_camera;
+    @BindView(R.id.add_article_pic)
+    ImageView add_article_pic;
+
+    private TitleFragmentListAdapter mAdapter;
+
+    private void initView() {
+        mAdapter = new TitleFragmentListAdapter(getChildFragmentManager());
+        mAdapter.add(FgtFindChild.newInstance(0), "全部");
+        //悬浮
+        ViewUtil.setImage(add_article_expand, ViewUtil.getNetImgByName("add_article_expand"));
+        if (!onlyChooseVideo) {
+            ViewUtil.setImage(add_article_iv, ViewUtil.getNetImgByName("add_article"));
+            ViewUtil.setImage(add_article_camera, ViewUtil.getNetImgByName("add_article_camera"));
+            ViewUtil.setImage(add_article_pic, ViewUtil.getNetImgByName("add_article_pic"));
+        }
+        ViewUtil.setVisibility(add_article, false);
+        ViewUtil.setVisibility(add_article_iv, false);
+        ViewUtil.setVisibility(add_article_camera, false);
+        ViewUtil.setVisibility(add_article_pic, false);
+        add_article.setOnClickListener(view -> {
+            if (onlyChooseVideo) {
+                Jump2View.getInstance().gotoActPublishArticle(MediaStore.Files.FileColumns.MEDIA_TYPE_VIDEO);
+            } else {
+                changeAddArticle(add_article_iv.getVisibility() == View.VISIBLE);
+            }
+        });
+        if (!onlyChooseVideo) {
+            add_article_camera.setOnClickListener(view -> {
+//                changeAddArticle(true);
+//                G.showToast("添加视频");
+                Jump2View.getInstance().gotoActPublishArticle(MediaStore.Files.FileColumns.MEDIA_TYPE_VIDEO);
+            });
+            add_article_pic.setOnClickListener(view -> {
+//                changeAddArticle(true);
+//                G.showToast("添加图片");
+                Jump2View.getInstance().gotoActPublishArticle(MediaStore.Files.FileColumns.MEDIA_TYPE_IMAGE);
+            });
+        }
+    }
+
+    private boolean onlyChooseVideo = true;//只选择视频
+
+    private void changeAddArticle(boolean isExpand) {
+        ViewUtil.setVisibility(add_article_iv, !isExpand);
+        ViewUtil.setVisibility(add_article_camera, !isExpand);
+        ViewUtil.setVisibility(add_article_pic, !isExpand);
+        add_article_expand.setAlpha(isExpand ? 1.0f : 0.0f);
+    }
+
+    @Override
+    public int getLayoutId() {
+        return R.layout.fgt_find2;
+    }
+
+    @Override
+    public void onViewCreated() {
+        activity = getActivity();
+        initView();
+        initData();
+    }
+
+    private void initData() {
+        //尝试获取缓存数据
+        List<ArticleTag> newList = DataUtil.getInstance().getCacheList(ApiKey.articles_tags, ArticleTag.class);
+        if (ListUtil.isEmpty(newList)) {//这里有个bug,如果一开始有数据,等到服务器数据发生变化时,就会始终使用老的数据,除非有缓存时长限制,但是这样又导致数据不是最新的,所以在SysAppUtil中的checkNet方法直接更新该列表。
+            initNetData(true);
+        } else {
+            list.addAll(newList);
+            loadList();
+        }
+    }
+
+    @Override
+    public void initDataOnVisibleToUser() {
+
+    }
+
+    private void initNetData(final boolean loadPager) {
+        SheepApp.getInstance().getNetComponent().getApiService().getFindTagList()
+                .subscribeOn(Schedulers.io())
+                .observeOn(AndroidSchedulers.mainThread())
+                .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
+                    @Override
+                    public void onNext(BaseMessage baseMessage) {
+                        List<ArticleTag> newList = baseMessage.getDatas(ArticleTag.class);
+                        list.clear();
+                        list.addAll(newList);
+                        if (loadPager && !ListUtil.isEmpty(list)) {
+                            loadList();
+                        }
+                    }
+
+                    @Override
+                    public void onError(BaseMessage baseMessage) {
+                    }
+                });
+    }
+
+    //没有添加数据返回true
+    private void loadList() {
+        CommonUtil.getInstance().initUrlConfigByNet("awaken_on", new Action1<String>() {
+            @Override
+            public void call(String url) {
+                int awaken_on = NumberFormatUtils.parseInteger(url);
+                int count = 1;
+                for (ArticleTag findLabel : list) {
+                    switch (findLabel.getName()) {
+                        case "视频":
+                            mAdapter.add(FgtArticleVideo.newInstance(findLabel.getId()), findLabel.getName());
+                            break;
+                        default:
+                            mAdapter.add(FgtFindChild.newInstance(findLabel.getId()), findLabel.getName());
+                            break;
+                    }
+                    count++;
+                }
+                if (awaken_on == 1) {
+                    count++;
+                    mAdapter.add(new FgtWatchFocus(), "看点", 2);
+                }
+                pager.setAdapter(mAdapter);
+                indicator.setupWithViewPager(pager);
+                pager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
+                    @Override
+                    public void onPageScrolled(int i, float v, int i1) {
+
+                    }
+
+                    @Override
+                    public void onPageSelected(int i) {
+                        ViewUtil.setVisibility(add_article, mAdapter.getItem(i) instanceof FgtArticleVideo);
+                        FIND_TAG.onEvent("find_tag_name", ListUtil.hasIndex(list, i - 1) ? list.get(i - 1).getName() : "全部");
+                    }
+
+                    @Override
+                    public void onPageScrollStateChanged(int i) {
+
+                    }
+                });
+                CommonUtil.getInstance().reflex(indicator, activity);
+                pager.setOffscreenPageLimit(count);
+
+            }
+        });
+    }
+
+    private List<ArticleTag> list = ListUtil.emptyList();
+
+    //点击返回
+    public void onClickBackImg(View view) {
+        KeyEventUtil.sendKeyDownUp(KeyEvent.KEYCODE_BACK);
+    }
+}

+ 7 - 1
app/src/main/java/com/sheep/gamegroup/util/js/KFZSJs.java

@@ -10,6 +10,7 @@ import com.alibaba.fastjson.JSONObject;
 import com.sheep.gamegroup.absBase.AbsObserver;
 import com.sheep.gamegroup.model.entity.BaseMessage;
 import com.sheep.gamegroup.model.util.SheepSubscriber;
+import com.sheep.gamegroup.module.find.activity.ActFind;
 import com.sheep.gamegroup.module.user.activity.ActVip;
 import com.sheep.gamegroup.module.user.model.BuyVipReq;
 import com.sheep.gamegroup.module.user.model.TempUserResp;
@@ -20,6 +21,7 @@ import com.sheep.gamegroup.util.DataUtil;
 import com.sheep.gamegroup.util.DeviceUtil;
 import com.sheep.gamegroup.util.Jump2View;
 import com.sheep.gamegroup.util.LogUtil;
+import com.sheep.gamegroup.util.MainTab;
 import com.sheep.gamegroup.util.QQUtil;
 import com.sheep.gamegroup.util.SysAppUtil;
 import com.sheep.gamegroup.util.share.ShareLinkConfig;
@@ -96,7 +98,11 @@ public class KFZSJs {
 
     @JavascriptInterface
     public void gotoMain(int tab) {
-        Intent mainIntent = new Intent(activity, ActMain.class);
+        Class willClass = ActMain.class;
+        if(tab == MainTab.Fgt_Find.ordinal()){
+            willClass = ActFind.class;
+        }
+        Intent mainIntent = new Intent(activity, willClass);
         mainIntent.putExtra("SWITCH_TAB", tab);
         activity.startActivity(mainIntent);
     }

+ 102 - 0
app/src/main/res/layout/fgt_find2.xml

@@ -0,0 +1,102 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:background="@color/white">
+
+    <android.support.constraint.ConstraintLayout
+        android:id="@+id/layout_navigationBar"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:background="@color/bg_home_color"
+        android:paddingTop="@dimen/status_bar_height">
+
+        <ImageView
+            android:id="@+id/img_baseactivity_title"
+            android:layout_width="wrap_content"
+            android:layout_height="?attr/actionBarSize"
+            android:gravity="center_vertical"
+            android:paddingStart="@dimen/content_padding_20"
+            android:paddingEnd="@dimen/content_padding_20"
+            android:onClick="onClickBackImg"
+            android:scaleType="centerInside"
+            android:src="@drawable/narrow_back_white"
+            app:layout_constraintStart_toStartOf="parent"
+            app:layout_constraintTop_toTopOf="parent" />
+
+        <TextView
+            android:id="@+id/txt_baseactivity_title"
+            android:layout_width="wrap_content"
+            android:layout_height="?attr/actionBarSize"
+            android:layout_centerInParent="true"
+            android:gravity="center"
+            android:text="发现"
+            android:textColor="@color/white"
+            android:textSize="@dimen/text_size_4"
+            app:layout_constraintBottom_toBottomOf="@+id/img_baseactivity_title"
+            app:layout_constraintEnd_toEndOf="parent"
+            app:layout_constraintStart_toStartOf="parent"
+            app:layout_constraintTop_toTopOf="@+id/img_baseactivity_title" />
+    </android.support.constraint.ConstraintLayout>
+
+    <ImageView
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:adjustViewBounds="true"
+        android:scaleType="fitXY"
+        android:layout_below="@id/layout_navigationBar"
+        android:src="@drawable/skin_drawable_selector_bg_home_search" />
+
+    <android.support.design.widget.TabLayout
+        android:id="@+id/indicator"
+        style="@style/style_tab_2"
+        android:layout_below="@id/layout_navigationBar"
+        android:layout_marginTop="20dp" />
+
+    <android.support.v4.view.ViewPager
+        android:id="@+id/pager"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:layout_below="@id/indicator" />
+
+    <com.kfzs.duanduan.view.DragRelativeLayout
+        android:id="@+id/add_article"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_alignParentEnd="true"
+        android:layout_centerVertical="true">
+
+        <ImageView
+            android:id="@+id/add_article_iv"
+            android:layout_width="120dp"
+            android:layout_height="120dp"
+            android:src="@drawable/icon" />
+
+        <ImageView
+            android:id="@+id/add_article_expand"
+            android:layout_width="72dp"
+            android:layout_height="72dp"
+            android:layout_alignTop="@id/add_article_iv"
+            android:layout_alignEnd="@id/add_article_iv"
+            android:src="@drawable/icon" />
+
+        <ImageView
+            android:id="@+id/add_article_camera"
+            android:layout_width="25dp"
+            android:layout_height="22dp"
+            android:layout_marginStart="15dp"
+            android:layout_marginTop="18dp"
+            android:src="@drawable/icon" />
+
+        <ImageView
+            android:id="@+id/add_article_pic"
+            android:layout_width="26dp"
+            android:layout_height="25dp"
+            android:layout_alignEnd="@id/add_article_iv"
+            android:layout_alignBottom="@id/add_article_iv"
+            android:layout_marginEnd="22dp"
+            android:layout_marginBottom="19dp"
+            android:src="@drawable/icon" />
+    </com.kfzs.duanduan.view.DragRelativeLayout>
+</RelativeLayout>