Skip to content
This repository has been archived by the owner on May 28, 2024. It is now read-only.

Commit

Permalink
find 页拖曳调整;
Browse files Browse the repository at this point in the history
  • Loading branch information
OCNYang committed Dec 6, 2017
1 parent 83f04b8 commit 8d7da07
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,17 @@ public void initContentView() {
}

boolean isRestart = false;

private void initByRestart(Bundle savedInstanceState) {

mCurrentIndex = savedInstanceState.getString("mCurrentIndex");

isRestart = true;
Logger.e("恢复状态:" + mCurrentIndex);
mMeFragment = (MeFragment) sBaseFragmentManager.findFragmentByTag(ME_FRAGMENT);
if (sRecommendMains.getVisibility()==View.VISIBLE){
mNewsFragment = (NewsFragment) sBaseFragmentManager.findFragmentByTag(NEWS_FRAGMENT);}
if (sRecommendMains.getVisibility() == View.VISIBLE) {
mNewsFragment = (NewsFragment) sBaseFragmentManager.findFragmentByTag(NEWS_FRAGMENT);
}
mWechatFragment = (WechatFragment) sBaseFragmentManager.findFragmentByTag(WECHAT_FRAGMENT);
mFindFragment = (FindFragment) sBaseFragmentManager.findFragmentByTag(FIND_FRAGMENT);

Expand All @@ -116,7 +118,7 @@ public void initView(Bundle savedInstanceState) {

String startPage = WECHAT_FRAGMENT;
String s = (String) SPUtils.get(this, Const.OPENNEWS, "nomagic");
if (s.equals("magicopen")){
if (s.equals("magicopen")) {
sRecommendMains.setVisibility(View.VISIBLE);
startPage = NEWS_FRAGMENT;
}
Expand Down Expand Up @@ -183,10 +185,10 @@ private void showMeFragment() {
if (mMeFragment == null) {
mMeFragment = MeFragment.newInstance();
addFragment(R.id.framelayout_mains, mMeFragment, ME_FRAGMENT);
}else if (isRestart = true){
} else if (isRestart = true) {
getFragmentTransaction().show(mMeFragment).commit();
isRestart = false;
}else {
} else {
showFragment(mMeFragment);
}
}
Expand All @@ -198,8 +200,8 @@ private void showFindFragment() {
if (mFindFragment == null) {
mFindFragment = FindFragment.newInstance("", "");
addFragment(R.id.framelayout_mains, mFindFragment, FIND_FRAGMENT);
}else if (isRestart = true){
isRestart =false;
} else if (isRestart = true) {
isRestart = false;
getFragmentTransaction().show(mFindFragment).commit();
} else {
showFragment(mFindFragment);
Expand All @@ -214,8 +216,8 @@ private void showWechatFragment() {
if (mWechatFragment == null) {
mWechatFragment = mWechatFragment.newInstance("", "");
addFragment(R.id.framelayout_mains, mWechatFragment, WECHAT_FRAGMENT);
}else if (isRestart = true){
isRestart =false;
} else if (isRestart = true) {
isRestart = false;
getFragmentTransaction().show(mWechatFragment).commit();
} else {
showFragment(mWechatFragment);
Expand All @@ -231,11 +233,11 @@ private void showNewsFragment() {
sRecommendMains.setSelected(true);
}
if (mNewsFragment == null) {
Logger.e("恢复状态:"+"null");
Logger.e("恢复状态:" + "null");
mNewsFragment = NewsFragment.newInstance("a", "b");
addFragment(R.id.framelayout_mains, mNewsFragment, NEWS_FRAGMENT);
}else if (isRestart = true){
isRestart =false;
} else if (isRestart = true) {
isRestart = false;
getFragmentTransaction().show(mNewsFragment).commit();
} else {
showFragment(mNewsFragment);
Expand All @@ -257,7 +259,8 @@ private void hideAllFragment() {
hideFragment(mMeFragment);
}
if (sRecommendMains.getVisibility() == View.VISIBLE) {
sRecommendMains.setSelected(false);}
sRecommendMains.setSelected(false);
}
sFindtravelMains.setSelected(false);
sCityfinderMains.setSelected(false);
sMeMains.setSelected(false);
Expand All @@ -273,19 +276,19 @@ public void onClick(View view) {
switch (view.getId()) {
case R.id.recommend_mains:
if (!mCurrentIndex.equals(NEWS_FRAGMENT))
switchToFragment(NEWS_FRAGMENT);
switchToFragment(NEWS_FRAGMENT);
break;
case R.id.cityfinder_mains:
if (!mCurrentIndex.equals(WECHAT_FRAGMENT))
switchToFragment(WECHAT_FRAGMENT);
switchToFragment(WECHAT_FRAGMENT);
break;
case R.id.findtravel_mains:
if (!mCurrentIndex.equals(FIND_FRAGMENT))
switchToFragment(FIND_FRAGMENT);
switchToFragment(FIND_FRAGMENT);
break;
case R.id.me_mains:
if (!mCurrentIndex.equals(ME_FRAGMENT))
switchToFragment(ME_FRAGMENT);
switchToFragment(ME_FRAGMENT);
break;
}
}
Expand Down
21 changes: 20 additions & 1 deletion app/src/main/java/com/ocnyang/qbox/app/network/Network.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.ocnyang.qbox.app.network;

import android.os.Environment;
import android.util.Log;

import com.ocnyang.qbox.app.network.api.ChinaCalendarApi;
Expand All @@ -15,6 +16,10 @@
import com.ocnyang.qbox.app.network.api.TextJokeApi;
import com.ocnyang.qbox.app.network.api.WechatApi;

import java.io.File;
import java.util.concurrent.TimeUnit;

import okhttp3.Cache;
import okhttp3.OkHttpClient;
import retrofit2.CallAdapter;
import retrofit2.Converter;
Expand Down Expand Up @@ -56,7 +61,21 @@ public class Network {
public static ChinaCalendarApi sChinaCalendarApi;
public static CityApi sCityApi;


private static final long cacheSize = 1024 * 1024 * 20;// 缓存文件最大限制大小20M
private static String cacheDirectory = Environment.getExternalStorageDirectory() + "/okttpcaches"; // 设置缓存文件路径
private static Cache cache = new Cache(new File(cacheDirectory), cacheSize); //
private static final OkHttpClient cacheClient;

static {
//如果无法生存缓存文件目录,检测权限使用已经加上,检测手机是否把文件读写权限禁止了
OkHttpClient.Builder builder = new OkHttpClient.Builder();
builder.connectTimeout(8, TimeUnit.SECONDS); // 设置连接超时时间
builder.writeTimeout(8, TimeUnit.SECONDS);// 设置写入超时时间
builder.readTimeout(8, TimeUnit.SECONDS);// 设置读取数据超时时间
builder.retryOnConnectionFailure(true);// 设置进行连接失败重试
builder.cache(cache);// 设置缓存
cacheClient = builder.build();
}

private static OkHttpClient okHttpClient = new OkHttpClient();
private static Converter.Factory gsonConverterFactory = GsonConverterFactory.create();
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/layout/fragment_find.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="bottom"
android:clipChildren="false"
android:orientation="vertical"
android:weightSum="8">

Expand All @@ -34,6 +35,7 @@
android:id="@+id/Recycler_find"
android:layout_width="match_parent"
android:layout_height="160dp"
android:clipChildren="false"
android:layout_weight="0"/>

<LinearLayout
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/ocnyang.xml
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
style="@style/aboutme.text"
android:layout_weight="1"
android:gravity="center_vertical"
android:text="新浪微博:欧欧心心"
android:text="新浪微博:欧神杨"
android:textStyle="bold"/>

<TextView
Expand Down

0 comments on commit 8d7da07

Please sign in to comment.