From bab18bd699a546b7f2e30b6b8faa54f3da7d077f Mon Sep 17 00:00:00 2001 From: fan123199 Date: Tue, 18 Apr 2017 22:20:18 +0800 Subject: [PATCH] add followings, fix settings UI. --- .idea/dictionaries/fdx.xml | 1 + README.md | 6 + app/app.iml | 3 +- app/build.gradle | 17 +-- app/src/main/AndroidManifest.xml | 4 + .../v2ex/{utils => network}/GsonRequest.java | 2 +- .../{utils => network}/MyGsonRequest.java | 4 +- .../java/im/fdx/v2ex/network/NetManager.java | 9 +- .../java/im/fdx/v2ex/ui/MemberActivity.java | 4 +- .../im/fdx/v2ex/ui/NotificationAdapter.java | 9 +- .../java/im/fdx/v2ex/ui/SettingsActivity.java | 41 +++++- .../fdx/v2ex/ui/details/DetailsActivity.java | 4 +- .../fdx/v2ex/ui/details/DetailsAdapter.java | 8 +- .../im/fdx/v2ex/ui/favor/FavorActivity.java | 40 ++++++ .../fdx/v2ex/ui/favor/MyViewPagerAdapter.java | 46 +++++++ .../fdx/v2ex/ui/favor/NodeFavorFragment.java | 128 ++++++++++++++++++ .../im/fdx/v2ex/ui/main/MainActivity.java | 14 +- .../fdx/v2ex/ui/main/MyViewPagerAdapter.java | 2 +- .../im/fdx/v2ex/ui/main/TopicsFragment.java | 50 +++++-- .../im/fdx/v2ex/ui/main/TopicsRVAdapter.java | 5 +- .../im/fdx/v2ex/ui/node/AllNodesActivity.java | 2 +- .../im/fdx/v2ex/ui/node/AllNodesAdapter.java | 29 +++- .../im/fdx/v2ex/ui/node/NodeActivity.java | 12 +- .../java/im/fdx/v2ex/ui/node/NodeAdapter.java | 16 ++- ...hManager.java => SmoothLayoutManager.java} | 8 +- .../utils/{TimeHelper.java => TimeUtil.java} | 2 +- .../res/drawable/ic_favorite_black_24dp.xml | 9 ++ .../ic_favorite_border_black_24dp.xml | 9 ++ .../res/layout/activity_follow_activity.xml | 43 ++++++ app/src/main/res/layout/activity_node.xml | 2 +- app/src/main/res/layout/favor_node.xml | 12 ++ app/src/main/res/layout/fragment_item.xml | 20 +++ .../main/res/layout/fragment_item_list.xml | 13 ++ .../main/res/layout/fragment_tab_article.xml | 2 +- app/src/main/res/layout/item_all_nodes.xml | 35 +++-- app/src/main/res/layout/item_node.xml | 14 +- app/src/main/res/layout/item_notification.xml | 9 +- .../res/menu/menu_activity_nav_drawer.xml | 4 + app/src/main/res/values-zh/strings.xml | 3 +- app/src/main/res/values/dimens.xml | 1 + app/src/main/res/values/strings.xml | 8 ++ app/src/main/res/xml/preference.xml | 7 +- .../im/fdx/v2ex/utils/TimeHelperTest.java | 6 +- 43 files changed, 546 insertions(+), 117 deletions(-) rename app/src/main/java/im/fdx/v2ex/{utils => network}/GsonRequest.java (98%) rename app/src/main/java/im/fdx/v2ex/{utils => network}/MyGsonRequest.java (94%) create mode 100644 app/src/main/java/im/fdx/v2ex/ui/favor/FavorActivity.java create mode 100644 app/src/main/java/im/fdx/v2ex/ui/favor/MyViewPagerAdapter.java create mode 100644 app/src/main/java/im/fdx/v2ex/ui/favor/NodeFavorFragment.java rename app/src/main/java/im/fdx/v2ex/utils/{SmoothManager.java => SmoothLayoutManager.java} (82%) rename app/src/main/java/im/fdx/v2ex/utils/{TimeHelper.java => TimeUtil.java} (99%) create mode 100644 app/src/main/res/drawable/ic_favorite_black_24dp.xml create mode 100644 app/src/main/res/drawable/ic_favorite_border_black_24dp.xml create mode 100644 app/src/main/res/layout/activity_follow_activity.xml create mode 100644 app/src/main/res/layout/favor_node.xml create mode 100644 app/src/main/res/layout/fragment_item.xml create mode 100644 app/src/main/res/layout/fragment_item_list.xml diff --git a/.idea/dictionaries/fdx.xml b/.idea/dictionaries/fdx.xml index 984fa8cf..07d18822 100644 --- a/.idea/dictionaries/fdx.xml +++ b/.idea/dictionaries/fdx.xml @@ -3,6 +3,7 @@ fdx httpcode + jiang jsoup nodename paddings diff --git a/README.md b/README.md index d9d731b5..cfc033df 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/app/app.iml b/app/app.iml index 5f6fc85c..67822c2c 100644 --- a/app/app.iml +++ b/app/app.iml @@ -34,7 +34,6 @@ - @@ -42,6 +41,7 @@ + @@ -91,6 +91,7 @@ + diff --git a/app/build.gradle b/app/build.gradle index 054447bf..987b95ac 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -10,8 +10,8 @@ android { applicationId "im.fdx.v2ex" minSdkVersion 19 targetSdkVersion 25 - versionCode 4 - versionName "1.3" + versionCode 5 + versionName "1.4" } lintOptions { @@ -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 @@ -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' diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index b98e5ad5..d34cefef 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -209,6 +209,10 @@ + + \ No newline at end of file diff --git a/app/src/main/java/im/fdx/v2ex/utils/GsonRequest.java b/app/src/main/java/im/fdx/v2ex/network/GsonRequest.java similarity index 98% rename from app/src/main/java/im/fdx/v2ex/utils/GsonRequest.java rename to app/src/main/java/im/fdx/v2ex/network/GsonRequest.java index dfc727b4..f972cdab 100644 --- a/app/src/main/java/im/fdx/v2ex/utils/GsonRequest.java +++ b/app/src/main/java/im/fdx/v2ex/network/GsonRequest.java @@ -1,4 +1,4 @@ -package im.fdx.v2ex.utils; +package im.fdx.v2ex.network; import android.util.Log; import android.widget.LinearLayout; diff --git a/app/src/main/java/im/fdx/v2ex/utils/MyGsonRequest.java b/app/src/main/java/im/fdx/v2ex/network/MyGsonRequest.java similarity index 94% rename from app/src/main/java/im/fdx/v2ex/utils/MyGsonRequest.java rename to app/src/main/java/im/fdx/v2ex/network/MyGsonRequest.java index 6bbec5ea..b0fee739 100644 --- a/app/src/main/java/im/fdx/v2ex/utils/MyGsonRequest.java +++ b/app/src/main/java/im/fdx/v2ex/network/MyGsonRequest.java @@ -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. */ diff --git a/app/src/main/java/im/fdx/v2ex/network/NetManager.java b/app/src/main/java/im/fdx/v2ex/network/NetManager.java index 3f4561f7..ad1dde37 100644 --- a/app/src/main/java/im/fdx/v2ex/network/NetManager.java +++ b/app/src/main/java/im/fdx/v2ex/network/NetManager.java @@ -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; @@ -193,7 +193,7 @@ public static List parseTopicLists(Document html, int source) { createdOriginal = smallItem.split("•")[1]; break; } - created = TimeHelper.toLong(createdOriginal); + created = TimeUtil.toLong(createdOriginal); } topicModel.setReplies(replies); topicModel.setContent(""); @@ -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; @@ -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 = ""; @@ -381,7 +380,7 @@ public static ArrayList 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); diff --git a/app/src/main/java/im/fdx/v2ex/ui/MemberActivity.java b/app/src/main/java/im/fdx/v2ex/ui/MemberActivity.java index 364bfd2d..43dc011f 100644 --- a/app/src/main/java/im/fdx/v2ex/ui/MemberActivity.java +++ b/app/src/main/java/im/fdx/v2ex/ui/MemberActivity.java @@ -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; @@ -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())) { diff --git a/app/src/main/java/im/fdx/v2ex/ui/NotificationAdapter.java b/app/src/main/java/im/fdx/v2ex/ui/NotificationAdapter.java index 758380a0..e42bb898 100644 --- a/app/src/main/java/im/fdx/v2ex/ui/NotificationAdapter.java +++ b/app/src/main/java/im/fdx/v2ex/ui/NotificationAdapter.java @@ -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; @@ -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()); diff --git a/app/src/main/java/im/fdx/v2ex/ui/SettingsActivity.java b/app/src/main/java/im/fdx/v2ex/ui/SettingsActivity.java index b5dad383..fc6cb6ca 100644 --- a/app/src/main/java/im/fdx/v2ex/ui/SettingsActivity.java +++ b/app/src/main/java/im/fdx/v2ex/ui/SettingsActivity.java @@ -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; @@ -76,6 +78,8 @@ public static class SettingsFragment extends PreferenceFragment implements Share SharedPreferences sharedPreferences; private ListPreference listPreference; + private int count; + public SettingsFragment() { } @@ -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(); @@ -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 { @@ -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() { diff --git a/app/src/main/java/im/fdx/v2ex/ui/details/DetailsActivity.java b/app/src/main/java/im/fdx/v2ex/ui/details/DetailsActivity.java index 67faf3d4..d45a8ee3 100644 --- a/app/src/main/java/im/fdx/v2ex/ui/details/DetailsActivity.java +++ b/app/src/main/java/im/fdx/v2ex/ui/details/DetailsActivity.java @@ -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; @@ -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 diff --git a/app/src/main/java/im/fdx/v2ex/ui/details/DetailsAdapter.java b/app/src/main/java/im/fdx/v2ex/ui/details/DetailsAdapter.java index 4f065b57..6008d59a 100644 --- a/app/src/main/java/im/fdx/v2ex/ui/details/DetailsAdapter.java +++ b/app/src/main/java/im/fdx/v2ex/ui/details/DetailsAdapter.java @@ -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; @@ -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); @@ -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())); diff --git a/app/src/main/java/im/fdx/v2ex/ui/favor/FavorActivity.java b/app/src/main/java/im/fdx/v2ex/ui/favor/FavorActivity.java new file mode 100644 index 00000000..5a6c304e --- /dev/null +++ b/app/src/main/java/im/fdx/v2ex/ui/favor/FavorActivity.java @@ -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); + + + } +} diff --git a/app/src/main/java/im/fdx/v2ex/ui/favor/MyViewPagerAdapter.java b/app/src/main/java/im/fdx/v2ex/ui/favor/MyViewPagerAdapter.java new file mode 100644 index 00000000..ab93c7cd --- /dev/null +++ b/app/src/main/java/im/fdx/v2ex/ui/favor/MyViewPagerAdapter.java @@ -0,0 +1,46 @@ +package im.fdx.v2ex.ui.favor; + +import android.app.Fragment; +import android.app.FragmentManager; +import android.os.Bundle; +import android.support.v13.app.FragmentPagerAdapter; + +import im.fdx.v2ex.ui.main.TopicsFragment; + +/** + * Created by fdx on 2017/4/13. + */ +class MyViewPagerAdapter extends FragmentPagerAdapter { + + public MyViewPagerAdapter(FragmentManager fm) { + super(fm); + } + + + String[] titles = new String[]{"节点收藏", "主题收藏", "特别关注"}; + + @Override + public Fragment getItem(int position) { + + if (position == 0) { + NodeFavorFragment nodeFavorFragment = new NodeFavorFragment(); + return nodeFavorFragment; + } else { + TopicsFragment topicFavorFragment = new TopicsFragment(); + Bundle bundle = new Bundle(); + bundle.putInt("type", position); + topicFavorFragment.setArguments(bundle); + return topicFavorFragment; + } + } + + @Override + public int getCount() { + return titles.length; + } + + @Override + public CharSequence getPageTitle(int position) { + return titles[position]; + } +} diff --git a/app/src/main/java/im/fdx/v2ex/ui/favor/NodeFavorFragment.java b/app/src/main/java/im/fdx/v2ex/ui/favor/NodeFavorFragment.java new file mode 100644 index 00000000..205fac27 --- /dev/null +++ b/app/src/main/java/im/fdx/v2ex/ui/favor/NodeFavorFragment.java @@ -0,0 +1,128 @@ +package im.fdx.v2ex.ui.favor; + +import android.app.Fragment; +import android.content.Context; +import android.net.Uri; +import android.os.Bundle; +import android.support.v7.widget.GridLayoutManager; +import android.support.v7.widget.RecyclerView; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import org.jsoup.Jsoup; +import org.jsoup.nodes.Element; +import org.jsoup.select.Elements; +import org.w3c.dom.Node; + +import java.io.IOException; +import java.util.ArrayList; + +import im.fdx.v2ex.R; +import im.fdx.v2ex.model.NodeModel; +import im.fdx.v2ex.network.HttpHelper; +import im.fdx.v2ex.network.NetManager; +import im.fdx.v2ex.ui.node.AllNodesAdapter; +import im.fdx.v2ex.ui.node.NodeAdapter; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Request; +import okhttp3.Response; + + +/** + * A simple {@link Fragment} subclass. + * Activities that contain this fragment must implement the + */ +public class NodeFavorFragment extends Fragment { + + private ArrayList nodeModels; + private final String url = "https://www.v2ex.com/my/nodes"; + private View view; + + public NodeFavorFragment() { + // Required empty public constructor + } + + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + // Inflate the layout for this fragment + view = inflater.inflate(R.layout.favor_node, container, false); + + + RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.rv_node); + + final AllNodesAdapter adapter = new AllNodesAdapter(getActivity(), true); + recyclerView.setAdapter(adapter); + recyclerView.setLayoutManager(new GridLayoutManager(getActivity(), 3)); + + HttpHelper.OK_CLIENT.newCall(new Request.Builder() + .headers(HttpHelper.baseHeaders) + .url(url) + .build()).enqueue(new Callback() { + @Override + public void onFailure(Call call, IOException e) { + + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + + if (response.code() != 200) { + NetManager.dealError(); + return; + } + + nodeModels = parseToNode(response.body().string()); + adapter.addAll(nodeModels); + getActivity().runOnUiThread(new Runnable() { + @Override + public void run() { + adapter.notifyDataSetChanged(); + + } + }); + } + }); + + + return view; + } + + + @Override + public void onDestroyView() { + super.onDestroyView(); + + } + + private ArrayList parseToNode(String string) { + Element element = Jsoup.parse(string).body(); + + ArrayList nodeModels = new ArrayList<>(); + Elements items = element.getElementsByClass("grid_item"); + + for (Element item : items) { + NodeModel nodeModel = new NodeModel(); + String id = item.attr("id").substring(2); + nodeModel.setId(Long.valueOf(id)); + + String title = item.getElementsByTag("div").first().ownText().trim(); + nodeModel.setTitle(title); + String name = item.attr("href").replace("/go/", ""); + nodeModel.setName(name); + + String num = item.getElementsByTag("span").first().ownText().trim(); + + nodeModel.setTopics(Integer.parseInt(num)); + + String imageUrl = item.getElementsByTag("img").first().attr("src"); + nodeModel.setAvatar_large(imageUrl); + nodeModels.add(nodeModel); + } + + return nodeModels; + } +} diff --git a/app/src/main/java/im/fdx/v2ex/ui/main/MainActivity.java b/app/src/main/java/im/fdx/v2ex/ui/main/MainActivity.java index d6fde61c..c6d016d1 100644 --- a/app/src/main/java/im/fdx/v2ex/ui/main/MainActivity.java +++ b/app/src/main/java/im/fdx/v2ex/ui/main/MainActivity.java @@ -52,10 +52,11 @@ import im.fdx.v2ex.ui.MemberActivity; import im.fdx.v2ex.ui.NotificationActivity; import im.fdx.v2ex.ui.SettingsActivity; +import im.fdx.v2ex.ui.favor.FavorActivity; import im.fdx.v2ex.ui.node.AllNodesActivity; 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; @@ -247,6 +248,7 @@ public void onTabReselected(TabLayout.Tab tab) { private void showDailyAndNotification(boolean visible) { navigationView.getMenu().findItem(R.id.nav_notification).setVisible(visible); navigationView.getMenu().findItem(R.id.nav_daily).setVisible(visible); + navigationView.getMenu().findItem(R.id.nav_favor).setVisible(visible); MainActivity.this.invalidateOptionsMenu(); } @@ -265,7 +267,7 @@ private void showDailyAndNotification(boolean visible) { private void shrinkFab() { fab.animate().rotation(360f) - .setDuration(500).start(); + .setDuration(1000).start(); } @@ -355,6 +357,12 @@ public boolean onNavigationItemSelected(@NonNull MenuItem item) { // intent.setAction("im.fdx.v2ex.notification"); startActivity(intent); break; + + case R.id.nav_favor: + Intent intentFavor = new Intent(this, FavorActivity.class); + startActivity(intentFavor); + + break; case R.id.nav_testMenu2: startActivity(new Intent(this, WebViewActivity.class)); @@ -488,7 +496,7 @@ private String parseDailyOnce(String string) { } // location.href = '/mission/daily/redeem?once=83270'; String onceOriginal = onceElement.attr("onClick"); - return TimeHelper.getNum(onceOriginal); + return TimeUtil.getNum(onceOriginal); } @Override diff --git a/app/src/main/java/im/fdx/v2ex/ui/main/MyViewPagerAdapter.java b/app/src/main/java/im/fdx/v2ex/ui/main/MyViewPagerAdapter.java index 7d79e97e..72a8c13d 100644 --- a/app/src/main/java/im/fdx/v2ex/ui/main/MyViewPagerAdapter.java +++ b/app/src/main/java/im/fdx/v2ex/ui/main/MyViewPagerAdapter.java @@ -21,7 +21,7 @@ * 从MainActivity分离出来. 用了FragmentStatePagerAdapter 替代FragmentPagerAdapter,才可以动态切换Fragment * 目前实现了两种视图。用JsonAPI+Volley 和 模拟web + okhttp */ -public class MyViewPagerAdapter extends FragmentStatePagerAdapter { +class MyViewPagerAdapter extends FragmentStatePagerAdapter { private List mFragments = new ArrayList<>(); private List mTabTitles = new ArrayList<>(); diff --git a/app/src/main/java/im/fdx/v2ex/ui/main/TopicsFragment.java b/app/src/main/java/im/fdx/v2ex/ui/main/TopicsFragment.java index 7ac4ebde..b530272a 100644 --- a/app/src/main/java/im/fdx/v2ex/ui/main/TopicsFragment.java +++ b/app/src/main/java/im/fdx/v2ex/ui/main/TopicsFragment.java @@ -18,6 +18,8 @@ import android.view.ViewGroup; import android.view.animation.Animation; import android.view.animation.TranslateAnimation; +import android.widget.RelativeLayout; +import android.widget.TextView; import com.android.volley.Response; import com.android.volley.VolleyError; @@ -38,8 +40,8 @@ import im.fdx.v2ex.network.NetManager; import im.fdx.v2ex.network.VolleyHelper; import im.fdx.v2ex.utils.Keys; -import im.fdx.v2ex.utils.MyGsonRequest; -import im.fdx.v2ex.utils.SmoothManager; +import im.fdx.v2ex.network.MyGsonRequest; +import im.fdx.v2ex.utils.SmoothLayoutManager; import okhttp3.Call; import okhttp3.Callback; import okhttp3.Request; @@ -66,9 +68,9 @@ public class TopicsFragment extends Fragment { private SwipeRefreshLayout mSwipeLayout; private String mRequestURL; private int mMNodeID; - private String mTabs; private RecyclerView mRecyclerView; private FloatingActionButton fab; + private RelativeLayout container; // private OnFragmentInteractionListener mListener; @@ -101,13 +103,17 @@ public void onCreate(Bundle savedInstanceState) { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - final View layout = inflater.inflate(R.layout.fragment_tab_article, container, false); Bundle args = getArguments(); mMNodeID = args.getInt(Keys.KEY_COLUMN_ID, 0); - mTabs = args.getString(Keys.KEY_TAB); - - if (mMNodeID == LATEST_TOPICS) { + String mTabs = args.getString(Keys.KEY_TAB); + if (args.getInt("type", -1) == 1) { + mRequestURL = HTTPS_V2EX_BASE + "/my/topics"; + getTopicsByOK(mRequestURL); + } else if (args.getInt("type", -1) == 2) { + mRequestURL = HTTPS_V2EX_BASE + "/my/following"; + getTopicsByOK(mRequestURL); + } else if (mMNodeID == LATEST_TOPICS) { mRequestURL = NetManager.API_LATEST; getTopicsJsonByVolley(mRequestURL); } else if (mMNodeID == TOP_10_TOPICS) { @@ -141,7 +147,7 @@ public void onRefresh() { mRecyclerView = (RecyclerView) layout.findViewById(R.id.main_recycler_view); //这里用线性显示 类似于listView // mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity())); - mRecyclerView.setLayoutManager(new SmoothManager(getActivity())); + mRecyclerView.setLayoutManager(new SmoothLayoutManager(getActivity())); fab = (FloatingActionButton) getActivity().findViewById(R.id.fab_main); @@ -156,7 +162,6 @@ public void onScrolled(RecyclerView recyclerView, int dx, int dy) { animator.setDuration(1000); Animation animation = new TranslateAnimation(Animation.ABSOLUTE, Animation.ABSOLUTE, Animation.ABSOLUTE, 100); - Animation animation2 = new TranslateAnimation(Animation.ABSOLUTE, Animation.ABSOLUTE, Animation.ABSOLUTE, 100); animation.setRepeatCount(1); if (dy > 0) { @@ -188,10 +193,6 @@ private void showFab() { @Override public void onScrollStateChanged(RecyclerView recyclerView, int newState) { - - if (newState == RecyclerView.SCROLL_STATE_DRAGGING) { -// fab.hide(); - } super.onScrollStateChanged(recyclerView, newState); } }); @@ -200,6 +201,8 @@ public void onScrollStateChanged(RecyclerView recyclerView, int newState) { mRecyclerView.setAdapter(mAdapter); //大工告成 + this.container = (RelativeLayout) layout.findViewById(R.id.rv_container); + // TODO: 16/4/30 不用自定义的Listener。 因为子视图的点击问题,无法屏蔽父视图的点击。 // mRecyclerView.addOnItemTouchListener(new RecyclerTouchListener(getActivity(), // mRecyclerView, new EasyClickListener() { @@ -244,9 +247,26 @@ public void onFailure(Call call, IOException e) { public void onResponse(Call call, okhttp3.Response response) throws IOException { Document html = Jsoup.parse(response.body().string()); - List c = NetManager.parseTopicLists(html, 0); + List topicList = NetManager.parseTopicLists(html, 0); + + if (topicList == null || topicList.isEmpty()) { + final TextView child = new TextView(getActivity()); + child.setText("没有内容"); + getActivity().runOnUiThread(new Runnable() { + @Override + public void run() { + mSwipeLayout.setRefreshing(false); + RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); + params.addRule(RelativeLayout.CENTER_HORIZONTAL); + params.addRule(RelativeLayout.CENTER_VERTICAL); + container.addView(child, params); + } + }); + return; + } + mTopicModels.clear(); - mTopicModels.addAll(c); + mTopicModels.addAll(topicList); // XLog.tag("TopicFragment").d("done, get topic models"); handler.sendEmptyMessage(MSG_GET_DATA_BY_OK); } diff --git a/app/src/main/java/im/fdx/v2ex/ui/main/TopicsRVAdapter.java b/app/src/main/java/im/fdx/v2ex/ui/main/TopicsRVAdapter.java index 8a331a03..f7bd6c35 100644 --- a/app/src/main/java/im/fdx/v2ex/ui/main/TopicsRVAdapter.java +++ b/app/src/main/java/im/fdx/v2ex/ui/main/TopicsRVAdapter.java @@ -23,8 +23,7 @@ import im.fdx.v2ex.ui.details.DetailsActivity; import im.fdx.v2ex.ui.node.NodeActivity; import im.fdx.v2ex.utils.Keys; -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 static im.fdx.v2ex.MyApp.USE_API; @@ -82,7 +81,7 @@ public void onBindViewHolder(RecyclerView.ViewHolder holder2, int position) { holder.tvReplyNumber.setText(sequence); holder.tvAuthor.setText(currentTopic.getMember().getUsername()); holder.tvNode.setText(currentTopic.getNode().getTitle()); - holder.tvCreated.setText(TimeHelper.getRelativeTime(currentTopic.getCreated())); + holder.tvCreated.setText(TimeUtil.getRelativeTime(currentTopic.getCreated())); Picasso.with(mContext).load(currentTopic.getMember().getAvatarNormalUrl()).into(holder.ivAvatar); holder.tvNode.setOnClickListener(listener); diff --git a/app/src/main/java/im/fdx/v2ex/ui/node/AllNodesActivity.java b/app/src/main/java/im/fdx/v2ex/ui/node/AllNodesActivity.java index 75551ec2..a179df48 100644 --- a/app/src/main/java/im/fdx/v2ex/ui/node/AllNodesActivity.java +++ b/app/src/main/java/im/fdx/v2ex/ui/node/AllNodesActivity.java @@ -75,7 +75,7 @@ public void onResponse(Call call, okhttp3.Response response) throws IOException }); - mAdapter = new AllNodesAdapter(); + mAdapter = new AllNodesAdapter(this, false); RecyclerView rvNode = (RecyclerView) findViewById(R.id.rv_node); RecyclerView.LayoutManager layoutManager = new StaggeredGridLayoutManager(3, VERTICAL); rvNode.setLayoutManager(layoutManager); diff --git a/app/src/main/java/im/fdx/v2ex/ui/node/AllNodesAdapter.java b/app/src/main/java/im/fdx/v2ex/ui/node/AllNodesAdapter.java index da23d91c..e2b8d83e 100644 --- a/app/src/main/java/im/fdx/v2ex/ui/node/AllNodesAdapter.java +++ b/app/src/main/java/im/fdx/v2ex/ui/node/AllNodesAdapter.java @@ -1,15 +1,18 @@ package im.fdx.v2ex.ui.node; +import android.content.Context; import android.content.Intent; import android.support.v7.widget.RecyclerView; import android.text.TextUtils; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.ImageView; import android.widget.TextView; import com.android.volley.toolbox.ImageLoader; import com.android.volley.toolbox.NetworkImageView; +import com.squareup.picasso.Picasso; import java.util.ArrayList; import java.util.List; @@ -29,10 +32,16 @@ public class AllNodesAdapter extends RecyclerView.Adapter { + private final boolean isShowImg; + private final Context context; private List mNodeModels = new ArrayList<>(); private List realAllNodes = new ArrayList<>(); - private final ImageLoader imageLoader = VolleyHelper.getInstance().getImageLoader(); + + public AllNodesAdapter(Context context, boolean showImage) { + this.context = context; + this.isShowImg = showImage; + } @Override public AllNodeViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { @@ -46,12 +55,15 @@ public AllNodeViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { public void onBindViewHolder(AllNodeViewHolder holder, int position) { final NodeModel node = mNodeModels.get(position); -// getNodeIcon(node.getId(),holder); - + if (isShowImg) { + Picasso.with(context).load(node.getAvatarLargeUrl()).into(holder.ivNodeIcon); + } else { + holder.ivNodeIcon.setVisibility(View.GONE); + } String a = String.format(Locale.CHINA, "%s (%s)", node.getTitle(), node.getTopics()); holder.tvNodeName.setText(a); - holder.tvNodeName.setOnClickListener(new View.OnClickListener() { + holder.itemView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(); @@ -79,6 +91,10 @@ public void setAllData(List nodeModels) { realAllNodes = nodeModels; } + public void addAll(List nodeModels) { + mNodeModels.addAll(nodeModels); + } + public void filter(String newText) { if (TextUtils.isEmpty(newText)) { @@ -105,12 +121,13 @@ public static class AllNodeViewHolder extends RecyclerView.ViewHolder { public TextView tvNodeName; - public NetworkImageView nivNodeIcon; + public ImageView ivNodeIcon; public AllNodeViewHolder(View itemView) { super(itemView); tvNodeName = (TextView) itemView.findViewById(R.id.tv_node_name); -// nivNodeIcon = (NetworkImageView) itemView.findViewById(R.id.iv_node_image); + ivNodeIcon = (ImageView) itemView.findViewById(R.id.iv_node_image); + // nivNodeIcon.setDefaultImageResId(R.drawable.ic_profile); diff --git a/app/src/main/java/im/fdx/v2ex/ui/node/NodeActivity.java b/app/src/main/java/im/fdx/v2ex/ui/node/NodeActivity.java index 5958965b..0cf3c5a1 100644 --- a/app/src/main/java/im/fdx/v2ex/ui/node/NodeActivity.java +++ b/app/src/main/java/im/fdx/v2ex/ui/node/NodeActivity.java @@ -13,12 +13,14 @@ import android.support.v7.widget.RecyclerView; import android.support.v7.widget.Toolbar; import android.view.View; +import android.widget.ImageView; import android.widget.RelativeLayout; import android.widget.TextView; import com.android.volley.toolbox.ImageLoader; import com.android.volley.toolbox.NetworkImageView; import com.elvishew.xlog.XLog; +import com.squareup.picasso.Picasso; import org.jsoup.Jsoup; import org.jsoup.nodes.Document; @@ -52,7 +54,7 @@ public class NodeActivity extends AppCompatActivity { private static final int MSG_ERROR_AUTH = 2; RelativeLayout rlNodeList; RelativeLayout rlNodeHeader; - NetworkImageView ivNodeIcon; + ImageView ivNodeIcon; TextView tvNodeName; TextView tvNodeHeader; TextView tvNodeNum; @@ -70,9 +72,8 @@ public void handleMessage(Message msg) { XLog.i("get handler msg " + msg.what); if (msg.what == MSG_GET_NODE_INFO) { - ivNodeIcon.setImageUrl(mNodeModel.getAvatarLargeUrl(), imageloader); + Picasso.with(NodeActivity.this).load(mNodeModel.getAvatarLargeUrl()).into(ivNodeIcon); XLog.d(mNodeModel.getTitle()); -// tvNodeName.setText(mNodeModel.getTitle()); collapsingToolbarLayout.setTitle(mNodeModel.getTitle()); collapsingToolbarLayout.setTitleEnabled(true); tvNodeHeader.setText(mNodeModel.getHeader()); @@ -88,7 +89,6 @@ public void handleMessage(Message msg) { }; private String nodeName; private NodeModel mNodeModel; - private AppBarLayout appBarLayout; private CollapsingToolbarLayout collapsingToolbarLayout; private String nodeTile; @@ -110,7 +110,7 @@ public void onClick(View v) { } - appBarLayout = (AppBarLayout) findViewById(R.id.appbar_node); + AppBarLayout appBarLayout = (AppBarLayout) findViewById(R.id.appbar_node); collapsingToolbarLayout = (CollapsingToolbarLayout) findViewById(R.id.ctl_node); @@ -142,7 +142,7 @@ public void onClick(View v) { rlNodeList = (RelativeLayout) findViewById(R.id.rl_node_list); - ivNodeIcon = (NetworkImageView) findViewById(R.id.iv_node_image); + ivNodeIcon = (ImageView) findViewById(R.id.iv_node_image); tvNodeName = (TextView) findViewById(R.id.tv_node_name); tvNodeHeader = (TextView) findViewById(R.id.tv_node_header); tvNodeNum = (TextView) findViewById(R.id.tv_topic_num); diff --git a/app/src/main/java/im/fdx/v2ex/ui/node/NodeAdapter.java b/app/src/main/java/im/fdx/v2ex/ui/node/NodeAdapter.java index d681b677..d87f4f4c 100644 --- a/app/src/main/java/im/fdx/v2ex/ui/node/NodeAdapter.java +++ b/app/src/main/java/im/fdx/v2ex/ui/node/NodeAdapter.java @@ -1,13 +1,16 @@ package im.fdx.v2ex.ui.node; +import android.content.Context; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.ImageView; import android.widget.TextView; import com.android.volley.toolbox.ImageLoader; import com.android.volley.toolbox.NetworkImageView; +import com.squareup.picasso.Picasso; import im.fdx.v2ex.R; import im.fdx.v2ex.model.NodeModel; @@ -20,12 +23,11 @@ public class NodeAdapter extends RecyclerView.Adapter { private NodeModel mNodeMode = new NodeModel(); - private ImageLoader mImageLoader; + private Context context; - public NodeAdapter(NodeModel nodeModel) { + public NodeAdapter(Context context, NodeModel nodeModel) { mNodeMode = nodeModel; - mImageLoader = VolleyHelper.getInstance().getImageLoader(); - + this.context = context; } @Override @@ -37,7 +39,7 @@ public NodeAdapter.NodeViewHolder onCreateViewHolder(ViewGroup parent, int viewT @Override public void onBindViewHolder(NodeViewHolder holder, int position) { holder.tvNodeName.setText(mNodeMode.getName()); - holder.ivNode.setImageUrl(mNodeMode.getAvatarLargeUrl(),mImageLoader); + Picasso.with(context).load(mNodeMode.getAvatarLargeUrl()).into(holder.ivNode); holder.tvNodeHeader.setText(mNodeMode.getHeader()); } @@ -49,13 +51,13 @@ public int getItemCount() { public class NodeViewHolder extends RecyclerView.ViewHolder{ public TextView tvNodeName; - public NetworkImageView ivNode; + public ImageView ivNode; public TextView tvNodeHeader; public NodeViewHolder(View itemView) { super(itemView); tvNodeName = (TextView) itemView.findViewById(R.id.tv_node_name); - ivNode = (NetworkImageView) itemView.findViewById(R.id.iv_node_image); + ivNode = (ImageView) itemView.findViewById(R.id.iv_node_image); tvNodeHeader = (TextView) itemView.findViewById(R.id.tv_node_header); diff --git a/app/src/main/java/im/fdx/v2ex/utils/SmoothManager.java b/app/src/main/java/im/fdx/v2ex/utils/SmoothLayoutManager.java similarity index 82% rename from app/src/main/java/im/fdx/v2ex/utils/SmoothManager.java rename to app/src/main/java/im/fdx/v2ex/utils/SmoothLayoutManager.java index ba55c2ec..4e7e5f00 100644 --- a/app/src/main/java/im/fdx/v2ex/utils/SmoothManager.java +++ b/app/src/main/java/im/fdx/v2ex/utils/SmoothLayoutManager.java @@ -6,13 +6,13 @@ import android.support.v7.widget.LinearSmoothScroller; import android.support.v7.widget.RecyclerView; -public class SmoothManager extends LinearLayoutManager { +public class SmoothLayoutManager extends LinearLayoutManager { - public SmoothManager(Context context) { + public SmoothLayoutManager(Context context) { super(context, VERTICAL, false); } - public SmoothManager(Context context, int orientation, boolean reverseLayout) { + public SmoothLayoutManager(Context context, int orientation, boolean reverseLayout) { super(context, orientation, reverseLayout); } @@ -32,7 +32,7 @@ public TopSnappedSmoothScroller(Context context) { @Override public PointF computeScrollVectorForPosition(int targetPosition) { - return SmoothManager.this + return SmoothLayoutManager.this .computeScrollVectorForPosition(targetPosition); } diff --git a/app/src/main/java/im/fdx/v2ex/utils/TimeHelper.java b/app/src/main/java/im/fdx/v2ex/utils/TimeUtil.java similarity index 99% rename from app/src/main/java/im/fdx/v2ex/utils/TimeHelper.java rename to app/src/main/java/im/fdx/v2ex/utils/TimeUtil.java index b6c8f7e6..6c2ef7a0 100644 --- a/app/src/main/java/im/fdx/v2ex/utils/TimeHelper.java +++ b/app/src/main/java/im/fdx/v2ex/utils/TimeUtil.java @@ -21,7 +21,7 @@ * Created by a708 on 15-9-9. * 获取相对时间 */ -public class TimeHelper { +public class TimeUtil { /** diff --git a/app/src/main/res/drawable/ic_favorite_black_24dp.xml b/app/src/main/res/drawable/ic_favorite_black_24dp.xml new file mode 100644 index 00000000..17cea927 --- /dev/null +++ b/app/src/main/res/drawable/ic_favorite_black_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_favorite_border_black_24dp.xml b/app/src/main/res/drawable/ic_favorite_border_black_24dp.xml new file mode 100644 index 00000000..feccba74 --- /dev/null +++ b/app/src/main/res/drawable/ic_favorite_border_black_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/layout/activity_follow_activity.xml b/app/src/main/res/layout/activity_follow_activity.xml new file mode 100644 index 00000000..2808b7ab --- /dev/null +++ b/app/src/main/res/layout/activity_follow_activity.xml @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/activity_node.xml b/app/src/main/res/layout/activity_node.xml index 3ec58aa0..cd264cc4 100644 --- a/app/src/main/res/layout/activity_node.xml +++ b/app/src/main/res/layout/activity_node.xml @@ -32,7 +32,7 @@ app:layout_collapseMode="parallax" app:layout_collapseParallaxMultiplier="0.3"> - + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_item.xml b/app/src/main/res/layout/fragment_item.xml new file mode 100644 index 00000000..ba5b613f --- /dev/null +++ b/app/src/main/res/layout/fragment_item.xml @@ -0,0 +1,20 @@ + + + + + + + diff --git a/app/src/main/res/layout/fragment_item_list.xml b/app/src/main/res/layout/fragment_item_list.xml new file mode 100644 index 00000000..5541f655 --- /dev/null +++ b/app/src/main/res/layout/fragment_item_list.xml @@ -0,0 +1,13 @@ + + diff --git a/app/src/main/res/layout/fragment_tab_article.xml b/app/src/main/res/layout/fragment_tab_article.xml index a598ca59..459bd703 100644 --- a/app/src/main/res/layout/fragment_tab_article.xml +++ b/app/src/main/res/layout/fragment_tab_article.xml @@ -1,6 +1,6 @@ - + + + android:textStyle="normal|bold" + tools:text="woshiname" + android:layout_marginTop="8dp" + app:layout_constraintTop_toBottomOf="@+id/iv_node_image" + android:layout_marginBottom="8dp" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintVertical_bias="0.0" + android:layout_marginLeft="8dp" + app:layout_constraintLeft_toLeftOf="parent" + android:layout_marginRight="8dp" + app:layout_constraintRight_toRightOf="parent" /> - + \ No newline at end of file diff --git a/app/src/main/res/layout/item_node.xml b/app/src/main/res/layout/item_node.xml index 0c27a216..8752a0fe 100644 --- a/app/src/main/res/layout/item_node.xml +++ b/app/src/main/res/layout/item_node.xml @@ -1,20 +1,22 @@ - \ No newline at end of file diff --git a/app/src/main/res/layout/item_notification.xml b/app/src/main/res/layout/item_notification.xml index 98183663..6158f18f 100644 --- a/app/src/main/res/layout/item_notification.xml +++ b/app/src/main/res/layout/item_notification.xml @@ -72,17 +72,18 @@ + android:layout_marginStart="0dp" + android:layout_marginEnd="16dp" + android:layout_marginLeft="0dp" + app:layout_constraintLeft_toLeftOf="@+id/iv_avatar_notification" /> \ No newline at end of file diff --git a/app/src/main/res/menu/menu_activity_nav_drawer.xml b/app/src/main/res/menu/menu_activity_nav_drawer.xml index 7ea94757..236a93a6 100644 --- a/app/src/main/res/menu/menu_activity_nav_drawer.xml +++ b/app/src/main/res/menu/menu_activity_nav_drawer.xml @@ -14,6 +14,10 @@ android:id="@+id/nav_node" android:icon="@drawable/ic_zoom_out_map_black_24dp" android:title="@string/all_nodes" /> + 反馈 通用 其他 - 对应用评分 + 评价应用 刚刚 在浏览器打开 探索路V2EX @@ -69,4 +69,5 @@ 确认 你有%d条未读消息 收藏 + 我的关注 \ No newline at end of file diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index d47f0277..b13b6419 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -12,4 +12,5 @@ 160dp 6dp 6dp + 16dp diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index c28bcbbd..ab8af60d 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -135,4 +135,12 @@ it is %d unread message Favor + My Follow + + + 一颗赛艇 + 不要搞个大新闻 + 无可奉告 + + diff --git a/app/src/main/res/xml/preference.xml b/app/src/main/res/xml/preference.xml index 3a43a5b6..0cef55d6 100644 --- a/app/src/main/res/xml/preference.xml +++ b/app/src/main/res/xml/preference.xml @@ -16,10 +16,15 @@ - + + diff --git a/app/src/test/java/im/fdx/v2ex/utils/TimeHelperTest.java b/app/src/test/java/im/fdx/v2ex/utils/TimeHelperTest.java index 8908b38a..ab9a06a2 100644 --- a/app/src/test/java/im/fdx/v2ex/utils/TimeHelperTest.java +++ b/app/src/test/java/im/fdx/v2ex/utils/TimeHelperTest.java @@ -1,11 +1,7 @@ package im.fdx.v2ex.utils; -import android.util.Log; - import org.junit.Test; -import static org.junit.Assert.*; - /** * Created by fdx on 2016/9/11. * fdx will maintain it @@ -13,7 +9,7 @@ public class TimeHelperTest { @Test public void getAbsoluteTime() throws Exception { - String s = TimeHelper.getAbsoluteTime(1341262360); + String s = TimeUtil.getAbsoluteTime(1341262360); // assertEquals("succeed", "2012-7-3 4:52:40",s); }