Skip to content

Commit

Permalink
add followings, fix settings UI.
Browse files Browse the repository at this point in the history
  • Loading branch information
fan123199 committed Apr 18, 2017
1 parent 47bec6b commit bab18bd
Show file tree
Hide file tree
Showing 43 changed files with 546 additions and 117 deletions.
1 change: 1 addition & 0 deletions .idea/dictionaries/fdx.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ The project guide me to start my project from zero.
##Change log



### v 1.4


add followings

### v1.3

add recent tab. title color change
Expand Down
3 changes: 2 additions & 1 deletion app/app.iml
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/debug" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/debug" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/test/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/androidTest/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/androidTest/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/test/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/assets" type="java-resource" />
Expand Down Expand Up @@ -91,6 +91,7 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/instant-run-support" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jniLibs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/pre-dexed" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/reload-dex" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/restart-dex" />
Expand Down
17 changes: 2 additions & 15 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ android {
applicationId "im.fdx.v2ex"
minSdkVersion 19
targetSdkVersion 25
versionCode 4
versionName "1.3"
versionCode 5
versionName "1.4"

}
lintOptions {
Expand All @@ -35,23 +35,12 @@ android {
}
}

// productFlavors {
// pro {
// applicationId "im.fdx.v2ex.pro"
// signingConfig signingConfigs.KeyForRelease
// }
// free {
// applicationId "im.fdx.v2ex.free"
// signingConfig signingConfigs.KeyForRelease
// }
// }
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}

//noinspection SpellCheckingInspection
dependencies {
// androidTestCompile 'com.android.support.test:runner:0.5'
// Set this dependency to use JUnit 4 rules
Expand All @@ -63,8 +52,6 @@ dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')

// compile 'com.belerweb:pinyin4j:2.5.0'
// compile 'com.github.bumptech.glide:okhttp3-integration:1.4.0' //图片加载库 glide 居然还要设置


compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.facebook.fresco:imagepipeline-okhttp3:1.1.0'
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,10 @@
<action android:name="im.fdx.v2ex.get.notificaiton" />
</intent-filter>
</receiver>

<activity
android:name=".ui.favor.FavorActivity"
android:exported="true"></activity>
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package im.fdx.v2ex.utils;
package im.fdx.v2ex.network;

import android.util.Log;
import android.widget.LinearLayout;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package im.fdx.v2ex.utils;
package im.fdx.v2ex.network;

import com.android.volley.DefaultRetryPolicy;
import com.android.volley.Response;

import java.lang.reflect.Type;

import im.fdx.v2ex.network.NetManager;

/**
* Created by a708 on 16-1-19.
*/
Expand Down
9 changes: 4 additions & 5 deletions app/src/main/java/im/fdx/v2ex/network/NetManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import im.fdx.v2ex.model.TopicModel;
import im.fdx.v2ex.utils.ContentUtils;
import im.fdx.v2ex.utils.HintUI;
import im.fdx.v2ex.utils.TimeHelper;
import im.fdx.v2ex.utils.TimeUtil;

import static java.lang.Integer.parseInt;

Expand Down Expand Up @@ -193,7 +193,7 @@ public static List<TopicModel> parseTopicLists(Document html, int source) {
createdOriginal = smallItem.split("•")[1];
break;
}
created = TimeHelper.toLong(createdOriginal);
created = TimeUtil.toLong(createdOriginal);
}
topicModel.setReplies(replies);
topicModel.setContent("");
Expand Down Expand Up @@ -246,7 +246,6 @@ public static NodeModel parseToNode(Document html) {
return nodeModel;
}

//// TODO: 2017/3/16 只有一页回复,这样是不行的
public static int getTotalPage(Element body) {

int currentPage = 0;
Expand Down Expand Up @@ -286,7 +285,7 @@ public static TopicModel parseResponseToTopic(Element body, long topicId) {

String time = createdUnformed.split("·")[1];
XLog.tag(TAG).d(createdUnformed + "||| " + time);
long created = TimeHelper.toLong(time);
long created = TimeUtil.toLong(time);
//long created = -1L;

String replyNum = "";
Expand Down Expand Up @@ -381,7 +380,7 @@ public static ArrayList<ReplyModel> parseResponseToReplay(Element body) {
// XLog.i(createdOriginal);
Element replyContent = item.getElementsByClass("reply_content").first();
// replyModel.setCreated(-1L);
replyModel.setCreated(TimeHelper.toLong(createdOriginal));
replyModel.setCreated(TimeUtil.toLong(createdOriginal));
replyModel.setMember(memberModel);
replyModel.setThanks(thanks);

Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/im/fdx/v2ex/ui/MemberActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
import im.fdx.v2ex.ui.main.TopicsRVAdapter;
import im.fdx.v2ex.utils.HintUI;
import im.fdx.v2ex.utils.Keys;
import im.fdx.v2ex.utils.TimeHelper;
import im.fdx.v2ex.utils.TimeUtil;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.Request;
Expand Down Expand Up @@ -449,7 +449,7 @@ private void showUser(String response) {
Picasso.with(this).load(member.getAvatarLargeUrl()).error(R.drawable.ic_person_outline_black_24dp).into(mIvAvatar);
mTvId.setText(getString(R.string.the_n_member, member.getId()));
mTvIntro.setText(member.getBio());
mTvUserCreated.setText(TimeHelper.getAbsoluteTime(Long.parseLong(member.getCreated())));
mTvUserCreated.setText(TimeUtil.getAbsoluteTime(Long.parseLong(member.getCreated())));

boolean debug_view = false;
if (debug_view || TextUtils.isEmpty(member.getBtc())) {
Expand Down
9 changes: 8 additions & 1 deletion app/src/main/java/im/fdx/v2ex/ui/NotificationAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import android.content.Intent;
import android.os.Build;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
Expand Down Expand Up @@ -73,7 +74,13 @@ public void onClick(View v) {


nholder.tvAction.setText(model.getType());
nholder.tvContent.setText(model.getContent());

if (TextUtils.isEmpty(model.getContent())) {
nholder.tvContent.setVisibility(View.GONE);
} else {
nholder.tvContent.setText(model.getContent());
}

Picasso.with(mContext).load(model.getMember().getAvatarNormalUrl()).into(nholder.ivAvatar);
nholder.tvUsername.setText(model.getMember().getUsername());
nholder.tvTime.setText(model.getTime());
Expand Down
41 changes: 35 additions & 6 deletions app/src/main/java/im/fdx/v2ex/ui/SettingsActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Bundle;
import android.preference.CheckBoxPreference;
Expand Down Expand Up @@ -76,6 +78,8 @@ public static class SettingsFragment extends PreferenceFragment implements Share
SharedPreferences sharedPreferences;
private ListPreference listPreference;

private int count;

public SettingsFragment() {
}

Expand Down Expand Up @@ -103,23 +107,18 @@ public boolean onPreferenceClick(Preference preference) {
.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {

dialog.dismiss();

}
})
.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {

removeCookie();
notifyAllActivities();
findPreference(PREF_LOGOUT).setEnabled(false);
sharedPreferences.edit().remove("is_login").apply();
dialog.dismiss();

HintUI.t(getActivity(), "已注销登录");

HintUI.t(getActivity(), "已退出登录");
}
});
alert.create().show();
Expand All @@ -133,6 +132,12 @@ public void onClick(DialogInterface dialog, int which) {
listPreference.setSummary(listPreference.getEntry());//初始化时设置summary
}

if (!sharedPreferences.getBoolean("pref_msg", false)) {
findPreference("pref_msg_period").setEnabled(false);
findPreference("pref_background_msg").setEnabled(false);

}

findPreference(PREF_RATES).setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
public boolean onPreferenceClick(Preference preference) {
try {
Expand All @@ -147,6 +152,30 @@ public boolean onPreferenceClick(Preference preference) {
}
});

PackageManager manager = getActivity().getPackageManager();
PackageInfo info;
try {
info = manager.getPackageInfo(getActivity().getPackageName(), 0);
findPreference("pref_version").setSummary(info.versionName);
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}


final String[] jiang = getResources().getStringArray(R.array.j);
count = 7;
findPreference("pref_version").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
if (count < 0) {
count = 7;
HintUI.t(getActivity(), jiang[(int) ((System.currentTimeMillis() / 100) % 3)]);
}
count--;
return true;
}
});

}

private void addSettings() {
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/im/fdx/v2ex/ui/details/DetailsActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
import im.fdx.v2ex.network.NetManager;
import im.fdx.v2ex.utils.HintUI;
import im.fdx.v2ex.utils.Keys;
import im.fdx.v2ex.utils.SmoothManager;
import im.fdx.v2ex.utils.SmoothLayoutManager;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.FormBody;
Expand Down Expand Up @@ -186,7 +186,7 @@ protected void onCreate(Bundle savedInstanceState) {
// mLayoutManager.scrollToPosition(0);
// mRCView.setLayoutManager(mLayoutManager);

LinearLayoutManager mLayoutManager = new SmoothManager(this);
LinearLayoutManager mLayoutManager = new SmoothLayoutManager(this);
mRCView.setLayoutManager(mLayoutManager);
mRCView.smoothScrollToPosition(POSITION_START);
//// 这个Scroll 到顶部的bug,卡了我一个星期,用了SO上的方法,自定义了一个LinearLayoutManager
Expand Down
8 changes: 3 additions & 5 deletions app/src/main/java/im/fdx/v2ex/ui/details/DetailsAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@
import im.fdx.v2ex.network.VolleyHelper;
import im.fdx.v2ex.ui.main.TopicsRVAdapter;
import im.fdx.v2ex.utils.HintUI;
import im.fdx.v2ex.view.CircleVImageView;
import im.fdx.v2ex.utils.TimeHelper;
import im.fdx.v2ex.utils.TimeUtil;
import im.fdx.v2ex.view.GoodTextView;
import okhttp3.Call;
import okhttp3.Callback;
Expand Down Expand Up @@ -137,7 +136,7 @@ public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
mainHolder.tvNode.setText(topic.getNode().getTitle());
TopicsRVAdapter.MyOnClickListener l = new TopicsRVAdapter.MyOnClickListener(mContext, topic);
mainHolder.tvNode.setOnClickListener(l);
mainHolder.tvCreated.setText(TimeHelper.getRelativeTime(topic.getCreated()));
mainHolder.tvCreated.setText(TimeUtil.getRelativeTime(topic.getCreated()));

// mainHolder.ivAvatar.setImageUrl(topic.getMember().getAvatarNormalUrl(), mImageLoader);
Picasso.with(mContext).load(topic.getMember().getAvatarNormalUrl()).into(mainHolder.ivAvatar);
Expand Down Expand Up @@ -239,8 +238,7 @@ public void run() {
}



itemVH.tvReplyTime.setText(TimeHelper.getRelativeTime(replyItem.getCreated()));
itemVH.tvReplyTime.setText(TimeUtil.getRelativeTime(replyItem.getCreated()));
itemVH.tvReplier.setText(replyItem.getMember().getUsername());
itemVH.tvThanks.setText(String.format(mContext.getResources().
getString(R.string.show_thanks), replyItem.getThanks()));
Expand Down
40 changes: 40 additions & 0 deletions app/src/main/java/im/fdx/v2ex/ui/favor/FavorActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package im.fdx.v2ex.ui.favor;

import android.support.design.widget.TabLayout;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.View;

import im.fdx.v2ex.R;

public class FavorActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_follow_activity);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
toolbar.setTitle("我的收藏");

setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);

toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onBackPressed();
}
});


MyViewPagerAdapter myViewPagerAdapter = new MyViewPagerAdapter(getFragmentManager());
TabLayout tabLayout = (TabLayout) findViewById(R.id.tl_favor);
ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager_follow);
viewPager.setAdapter(myViewPagerAdapter);
tabLayout.setupWithViewPager(viewPager);


}
}
Loading

0 comments on commit bab18bd

Please sign in to comment.