LightBlog

vendredi 9 décembre 2016

ASUS ZenWatch 3 review

Not long after Android Wear's inception, ASUS entered the smartwatch market with the original ASUS ZenWatch. Although it didn't quite offer the same level of appeal as the circular Moto 360, it marked the beginning of one of the best Android Wear lines to-date.

Two years and one iteration after its debut, the ZenWatch line is going circular with the ZenWatch 3; but does ASUS' latest smartwatch offer a better experience than its competitors? Let's find out with our comprehensive ASUS ZenWatch 3 review!

Design

Asus ZenWatch 3 review

The ZenWatch 3 is available in three color options: Rose Gold, Silver, and Gunmetal (pictured above). Perhaps the most compelling design aspect is the watch face; a circular display is surrounded by an accented, diamond cut bezel, which meets with the device's housing. Unlike the Moto 360, the ZenWatch 3 manages to pull this circular design off without a "flat tire." There's also still an ambient light sensor for automatic brightness.

asus-zenwatch-3-10

Encased in a 316L stainless steel body, the ZenWatch 3 certainly gives off a premium vibe from a material perspective. Its lugs may appear a bit unusual at first glance, but they actually compliment the rest of the design quite nicely with their subtlety. The wrist strap attachment mechanism is easy to use with its quick release pin, although it is proprietary, so you won't be able to easily use third party bands. ASUS is planning to sell both leather and rubber bands separately, each available in dark brown and beige.

asus-zenwatch-3-12

With that said, the leather wrist strap that comes with the watch is surprisingly good, offering a good deal of both comfort and style. It may, however, be a tad too small for those with very large wrists. Despite having relatively small wrists myself, the ZenWatch's band fit around the middle notch. If you're worried about this, you should consider trying on the watch in a retail store before purchasing to make sure it fits well.

asus-zenwatch-3-4

ASUS has also included three side buttons on the ZenWatch 3, all of which are satisfyingly tactile. Functionally speaking, the bottom button turns on airplane mode, the center button functions as a back button, and the top button can be set to launch an app of your choice.

I would have preferred just a single customizable side button

However, I very rarely found myself using these buttons, and often opted to interact with the touch screen instead. Quite frankly, three individual buttons feels excessive from a design perspective and overly complicated from a user experience perspective, so I would have preferred just a single customizable side button. Still, the buttons that ASUS has included both look and feel very premium.

asus-zenwatch-3-19

All things considered, the ZenWatch 3 offers a unique and stylish design. Some may argue that the gold bezel accent is a bit tacky, but I think it fits in well with the rest of the watch's aesthetic. For what it's worth, many of my friends commented on that aesthetic, and the general consensus was quite positive.

Display

asus-zenwatch-3-5

The ZenWatch 3 features a 1.39″ circular AMOLED display, with a resolution of 400 x 400. This is very likely the best display on a smartwatch to date.

The ambient light sensor allows for auto brightness, too, so you won't have to worry about constantly fine tuning the brightness manually. My only gripe with this is that the ZenWatch tends to lower auto brightness levels, which can be a bit problematic in bright environments. Hopefully a software update can tweak this a bit.

Sunlight readability is great


There also isn't a proper low brightness mode, so the watch's "theater mode" just turns the display off completely. Sunlight readability is great though, and probably some of the best you'll obtain from this form factor.

Performance

asus-zenwatch-3-13

One of the ZenWatch 3's key advantages over last year's Android Wear devices is its use of a Qualcomm Snapdragon Wear 2100. This chip has been touted to offer better performance and battery life since it's designed specifically for smartwatches.

The better performance claim seems to hold water, too, as the ZenWatch 3's performance was excellent during my testing. Swiping between cards and panels is very smooth, and it's generally difficult to find an appreciable amount of lag throughout the interface. There's also 512 MB of RAM, which is pretty much standard for Android Wear smartwatches.

Hardware

asus-zenwatch-3-14

With IP67 certification, the ZenWatch 3 is dust proof and water resistant, meaning that it can be submerged in up to one meter of water for thirty minutes. While we wouldn't recommend taking a shower with it, you won't have to worry about it getting wet when washing your hands or sweaty when exercising.

You'll be missing out on standalone Wear apps that use GPS as the potential for Android Pay


For connectivity, the watch primarily uses Bluetooth 4.1 to connect with your phone, but also supports Wi-Fi as a fallback. Unfortunately, it lacks GPS and NFC, so you'll be missing out on standalone Wear apps that use GPS as the potential for Android Pay, which will likely be coming in an upcoming update to Android Wear.

asus-zenwatch-3-6

It's also lacking a heart rate monitor, which is fairly disappointing considering many competing Android Wear options include one. It does, however, include both a microphone and speaker, meaning that you'll be able to place and receive calls on the watch directly. In my testing, both functioned about as well as I had expected.

Battery Life

ASUS claims the ZenWatch 3's 340mAh battery should last one to two days, depending on your usage. With moderate usage, I was able to get around twenty four hours per charge, which is about average for an Android Wear device.

asus-zenwatch-3-21

What makes the ZenWatch 3 particularly strong in this category is that it supports fast charging, for up to a 60% charge in fifteen minutes. In fact, the ZenWatch 3's fast charging speed made it possible to fully charge it while I got ready each morning, which usually means about forty minutes on the charger.

The included charger connects to the watch magnetically and transfers power through the watch's underside pins; it generally works quite well, too.

I would have liked to see a longer charging cable, however, as the one included in the box is a bit short at around a meter. Unfortunately, it doesn't seem that you can currently buy a longer or even extra charging cable for the ZenWatch 3, so you'll want to keep this in mind.

Software

asus-zenwatch-3-7

There's not much to say when it comes to software. Shipping with Android Wear, the ZenWatch 3 provides an identical core experience to other Android Wear smartwatches. I did notice a few minor bugs while using the ZenWatch 3, but those can most likely be blamed on Google. The good news is that it looks like this watch will be updated to Android Wear 2.0, so the software experience will likely improve over time.

The software experience will likely only improve over time

With that said, the general interface today sounds complicated but is actually quite easy to use. The watch's "home screen" is simply a watch face of your choice. From there, you can swipe up to see and act on different cards, which are added as you receive notifications on your phone. So, for example, if you receive a text message from a friend, you can simply swipe up on your watch to read it and have the opportunity to respond with your voice.

Since it is running Android Wear, the ZenWatch 3 is compatible with both Android 4.3 and higher as well as iOS 8.2 and higher, although features will vary by platform. Still, if you're using an iPhone, this is a great, cheaper alternative to the Apple Watch.

asus-zenwatch-3-15

ASUS has a ZenWatch Manager app, which adds over fifty different exclusive watch faces. That's an impressive number of options, but unfortunately there's only a few really good ones. Do keep in mind that you can always download third party watch faces from the Google Play store, however.

There's also ASUS ZenFit, a built-in app that tracks steps, workouts, and sleep. I found it to work very well overall, too, and was happy to see that includes Google Fit integration.

Gallery

Pricing and final thoughts

asus-zenwatch-3-8

The ASUS ZenWatch 3 is now available from various retailers for $229. That's a great bargain for what ASUS has brought to the table. It's very difficult not to fall in love with the ZenWatch 3 with its beautiful design, great display, excellent performance, and solid hardware. If you're looking for what is likely the most well-rounded smartwatch to date, look no further.

With that said, smartwatches largely still feel like a novelty. As much as I love the ZenWatch 3's hardware, the overall experience isn't enough for me to keep using it. Currently, it simply doesn't do enough more than my smartphone, which I always keep on me. I understand that some will absolutely love having notifications on their wrist, but I personally find it too distracting. I also don't request much more than my daily step count in terms of fitness, which my phone can also keep track of.

Also read:

Three things Android Wear needs to succeed

4 days ago

Here's the thing ― smartwatches, at least in their current form, aren't for everyone. If, however, you know the smartwatch concept is for you, the ZenWatch 3 is a great choice and you almost certainly won't be disappointed.



from Android Authority http://ift.tt/2hfgWAI
via IFTTT

Samsung Galaxy S7 and S7 Edge will jump straight to Android 7.1.1 Nougat

Samsung Galaxy S7 vs S7 Edge-6

Samsung Galaxy S7 vs S7 Edge-6

The Galaxy S7 and S7 Edge will forgo Android 7.0 and be upgraded straight to Android 7.1.1, Samsung has revealed. Samsung made the announcement in a response to a member of the Galaxy beta program who suggested that it upgrades the phones to the latest Android software, and provides a double-tap-to-wake function.

Samsung launched the beta program for the Galaxy S7 and S7 Edge in November to gather feedback on early builds of Android Nougat. The devices are currently running Android 6.0.1 Marshmallow, but Samsung is expected to officially update them to Nougat in early 2017.

See also:

Fourth Galaxy S7/S7 Edge Nougat beta adds Samsung Pass and Note app

2 days ago

Android 7.1.1 Nougat is the latest version of Android, announced by Google on December 5. The update – which delivers new features like app shortcuts and new emoji – is currently available for Nexus and Pixel devices, while third-party manufacturers now have access to the source code via the Android Open Source Project.

Meanwhile, Sony announced yesterday that it planned to be the first manufacturer, other than Google, to deliver Android 7.1.1 to one of its smartphones.



from Android Authority http://ift.tt/2hdCzUu
via IFTTT

Verizon won’t be rolling out Samsung Galaxy Note 7 shutdown update

verizon samsung logo

verizon samsung logo

Earlier today, Samsung confirmed that it will issue an update on Dec. 19 to all remaining Galaxy Note 7 phones in the US. The update will prevent the  device's battery from charging, which will of course make the phone useless. As it turns out, one major US carrier won't be rolling out that update: Verizon Wireless.

See also:

Why Samsung would be crazy to kill the Galaxy Note brand

October 27, 2016

In a statement, Verizon said the reason for its decision was that it feels Samsung's update will put the few remaining Note 7 owners at "added risk" if they cannot quickly switch to another phone. It added:

We will not push a software upgrade that will eliminate the ability for the Note7 to work as a mobile device in the heart of the holiday travel season. We do not want to make it impossible to contact family, first responders or medical professionals in an emergency situation.

Verizon notes that the "vast majority" of its Note 7 owners have already turned in the recalled phone for another model and repeated its call for all those users to "immediately stop using their devices" and turn them in or exchange it for another phone. It's very interesting move on Verizon's part, and it makes sense they don't want any of their users to be stranded if the Note 7 is their only phone. Then again, these users have been warned multiple times that they should return the phone, so some might argue that this update is necessary in order to get the remaining hold-out users onboard.

 

If you are a Note 7 owner with Verizon, how do you feel about the carrier taking a stand against offering Samsung's shutdown update?



from Android Authority http://ift.tt/2hfbY7f
via IFTTT

CM 14.1 rolling out for the 2014 Moto X, Galaxy S3, HTC One Max and more

cyanogenmod-cm-14-1-splash-screen

cyanogenmod-cm-14-1-splash-screen

The incessant CM 14.1 rollout continues unabated, with a big bunch of new supported devices added to its warm Nougat embrace. CM 14.1 is based on Android 7.1 Nougat, delivering the latest and greatest Android has to offer with some CyanogenMod specialties on top to devices that would otherwise languish back on Lollipop or worse.

Nightlies are now available for the following devices: Verizon Galaxy S3 (D2VZW); international Galaxy S3 (I9300); Verizon HTC One Max (T6VZW); HTC One Max (T6); LG G3 (Canada)(D852); Moto X 2014 (Victara); Redmi Note 3 (Kenzo); Redmi 3/Prime (ID0); Xiaomi Mi Max (Hydrogen); BQ Aquaris E5 4G (Vegetalte); Oppo N3 (N3); Oppo Find 7a (Find7); Oppo Find 7s (Find7s).

To download the firmware and CyanogenMod recovery, just hit the CM Downloads page and look for your device's codename on the left. When CM 14 dropped, Steve Kondik said CM was pushing for a return to its community-driven roots. With this level of support for various aging devices, they're certainly on the right track for regaining any fans they might have lost along the way.

When was the last time you flashed CyanogenMod? Will you be jumping on CM 14.1?



from Android Authority http://ift.tt/2hf6Obs
via IFTTT

ZTE offers Nougat preview program for Axon 7 owners in the US

ZTE Axon 7 NC 3-16

ZTE Axon 7 NC 3-16

Got a ZTE Axon 7? Live in the US? Fancy a bit of Nougat preview action? If your Axon 7 model number is A2017U then you're eligible to apply for ZTE's Nougat preview program for U.S. residents.

You'll have to be a member of the Z-Community to apply, but signing up for that is a simple enough affair. Then just head to the link below, check the box at the bottom and fill in the application form. It's unclear how fast you might receive access to the preview, but if you're interested in giving it a shot, here's the link.

APPLY FOR AXON 7 NOUGAT PREVIEW

The official Android Nougat update for the Axon 7 isn't expected until some time in early 2017 (if you believe ZTE Germany, it's scheduled for January). But the exact rollout date will likely depend on how smoothly the beta program goes and how many bugs need to be ironed out before going public.



from Android Authority http://ift.tt/2giHjnz
via IFTTT

Building a simple RSS reader – full tutorial with code

simple_rss_featured

simple_rss_featured

For this Android developer tutorial, we are going to create a simple RSS reader app. This app would fetch RSS feeds from a single, user specified internet address, and display the contents using a RecyclerView. If you aren't familiar with the RecyclerView widget, check out our previous tutorial on using a RecyclerView.

RSS, or Rich Site Summary, is an easy and efficient way to share snippets of frequently updated information such as blog entries or news items with subscribers. Almost every news website today has an RSS feed, and these feeds can be accessed through dedicated readers or through your favorite browser. An RSS feed usually contains a summary of the new content, rather than the entire news (or blog) article. To answer your question, yes, Android Authority has an RSS feed, available at http://ift.tt/1AXzcUX, and you should subscribe, if you haven't already. :D

Sample RSS Feed

An RSS feed is a plain text document, formatted in XML. Being XML, it is relatively easy for humans to read, and also not difficult for programs to parse. A sample XML document is shown below.

  <?xml version="1.0" encoding="UTF-8" ?>  <rss version="2.0">  <channel>   <title>RSS Title</title>   <description>This is an example of an RSS feed</description>   <link>http://ift.tt/1qi3fRV;   <lastBuildDate>Mon, 06 Sep 2010 00:01:00 +0000 </lastBuildDate>   <pubDate>Sun, 06 Sep 2009 16:20:00 +0000</pubDate>   <ttl>1800</ttl>     <item>    <title>Example entry</title>    <description>Here is some text containing an interesting description.</description>    <link>http://ift.tt/1qi3g8b;    <guid isPermaLink="true">7bd204c6-1655-4c27-aeee-53f933c5395f</guid>    <pubDate>Sun, 06 Sep 2009 16:20:00 +0000</pubDate>   </item>     <item>    <title>Second example entry</title>    <description>More text containing even more interesting description.</description>    <link>http://ift.tt/1qi3g8g;    <guid isPermaLink="true">7a4a56b6-1655-4c27-aeee-33e4453f2675</guid>    <pubDate>Sun, 06 Sep 2009 18:14:00 +0000</pubDate>   </item>    </channel>  </rss>  

We can see from the sample above, the feed has a title, a description, link, last build date, a publish date and a time to live. For this tutorial, we are only interested in the title, description and link.

There are also two items in the feed, and each has a title, a description and a link, along with a guid (globally unique identifier) and publish date. Most feed items have other tags, but, for our simple RSS  reader, we are only concerned with the title, description and link.

Preparing the project

Of course, the first thing we will do is create a new Android Studio project with an empty activity, which we've named SimpleRSSReader. In the AndroidManifiest.xml file, we include the INTERNET permission. Since the rss reader will fetch feeds from the internet, we must declare this permission.

  <uses-permission android:name="android.permission.INTERNET" />  

Also, we intend to use the support library, RecyclerView and design support library, so we add those to our app build.gradle file. The latest version as at publication is 25.0.1.

      compile 'com.android.support:appcompat-v7:25.0.1'      compile 'com.android.support:recyclerview-v7:25.0.1'      compile 'com.android.support:design:25.0.1'  

Great. With the initial setup complete, let's get to work.

Design the layout

For our simple app, we want the user to enter a target RSS feed url, and when he clicks a button, our rss reader app will fetch the feed and display the feed items in a recyclerview.

simple_rss_aa_fetched

simple_rss_aa_fetched
  <?xml version="1.0" encoding="utf-8"?>  <RelativeLayout xmlns:android="http://ift.tt/nIICcg"      xmlns:tools="http://ift.tt/LrGmb4"      android:id="@+id/activity_main"      android:layout_width="match_parent"      android:layout_height="match_parent"      android:paddingBottom="@dimen/activity_vertical_margin"      android:paddingLeft="@dimen/activity_horizontal_margin"      android:paddingRight="@dimen/activity_horizontal_margin"      android:paddingTop="@dimen/activity_vertical_margin"      tools:context="com.sample.foo.simplerssreader.MainActivity">        <Button          android:id="@+id/fetchFeedButton"          android:layout_width="wrap_content"          android:layout_height="wrap_content"          android:layout_alignParentEnd="true"          android:text="Fetch" />        <android.support.design.widget.TextInputLayout          android:id="@+id/textInputLayout"          android:layout_width="match_parent"          android:layout_height="wrap_content"          android:layout_marginEnd="@dimen/activity_horizontal_margin"          android:layout_toStartOf="@id/fetchFeedButton"          android:hint="Rss feed source">            <EditText              android:id="@+id/rssFeedEditText"              android:layout_width="match_parent"              android:layout_height="wrap_content" />        </android.support.design.widget.TextInputLayout>        <TextView          android:id="@+id/feedTitle"          android:layout_width="match_parent"          android:layout_height="wrap_content"          android:layout_below="@id/textInputLayout"          android:text="Feed Title: " />        <TextView          android:id="@+id/feedDescription"          android:layout_width="match_parent"          android:layout_height="wrap_content"          android:layout_below="@id/feedTitle"          android:text="Feed Description: " />        <TextView          android:id="@+id/feedLink"          android:layout_width="match_parent"          android:layout_height="wrap_content"          android:layout_below="@id/feedDescription"          android:text="Feed Link: " />        <android.support.v4.widget.SwipeRefreshLayout          android:id="@+id/swipeRefreshLayout"          android:layout_width="match_parent"          android:layout_height="match_parent"          android:layout_below="@id/feedLink"          android:layout_marginTop="@dimen/activity_vertical_margin">            <android.support.v7.widget.RecyclerView              android:id="@+id/recyclerView"              android:layout_width="match_parent"              android:layout_height="match_parent" />      </android.support.v4.widget.SwipeRefreshLayout>  </RelativeLayout>  

simple_rss_layout

simple_rss_layout

Did you notice that we enclosed our recyclerview within a SwipeRefreshLayout? A SwipeRefreshLayout is a design support library widget that allows users pull down to refresh, and shows a nice circular progress bar.

simple_rss_swipe_refresh

simple_rss_swipe_refresh

Creating the MainActivity

Within the MainActivity class, the first thing we do is define references to the EditText, the Button, RecyclerView and SwipeLayout. We also setup a click listener for the Button, and an OnRefreshListener for the SwipeRefreshLayout.

  public class MainActivity extends AppCompatActivity {        private RecyclerView mRecyclerView;      private EditText mEditText;      private Button mFetchFeedButton;      private SwipeRefreshLayout mSwipeLayout;      private TextView mFeedTitleTextView;      private TextView mFeedLinkTextView;      private TextView mFeedDescriptionTextView;        private List<RssFeedModel> mFeedModelList;      private String mFeedTitle;      private String mFeedLink;      private String mFeedDescription;        @Override      protected void onCreate(Bundle savedInstanceState) {          super.onCreate(savedInstanceState);          setContentView(R.layout.activity_main);            mRecyclerView = (RecyclerView) findViewById(R.id.recyclerView);          mEditText = (EditText) findViewById(R.id.rssFeedEditText);          mFetchFeedButton = (Button) findViewById(R.id.fetchFeedButton);          mSwipeLayout = (SwipeRefreshLayout) findViewById(R.id.swipeRefreshLayout);          mFeedTitleTextView = (TextView) findViewById(R.id.feedTitle);          mFeedDescriptionTextView = (TextView) findViewById(R.id.feedDescription);          mFeedLinkTextView = (TextView) findViewById(R.id.feedLink);            mRecyclerView.setLayoutManager(new LinearLayoutManager(this));            mFetchFeedButton.setOnClickListener(new View.OnClickListener() {              @Override              public void onClick(View view) {                  new FetchFeedTask().execute((Void) null);              }          });          mSwipeLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {              @Override              public void onRefresh() {                  new FetchFeedTask().execute((Void) null);              }          });      }  }  

Both the Button and SwipeRefreshLayout perform the same action, which is to start a new FetchFeedTask. The FetchFeedTask is an AsyncTask, which allows us perform possible long running tasks in a background thread. If you try to fetch feeds from a url on the main thread, your app will become unresponsive, and can appear to the user to have stopped working. Ever since Ice-cream Sandwich, Android no longer allows apps make network calls on the main thread. For a refresher on using AsyncTask, you can check out our previous article that discussed how to use a web API from your Android app.

The FetchFeedTask has three simple methods:

  1. onPreExecute, which is called before the long running task starts, and is executed on the calling thread.
  2. doInBackground, which is the long running task, and is executed in a new thread
  3. onPostExecute, which is called after the long running task is complete, and is executed on the calling thread.

Since Android allows manipulation of UI elements (Buttons, SwipeRefreshLayout, etc) only on the UI/Main thread, we can update the UI both in onPreExecute, and onPostExecute, but not in doInBackground.

  private class FetchFeedTask extends AsyncTask<Void, Void, Boolean> {            private String urlLink;            @Override          protected void onPreExecute() {              mSwipeLayout.setRefreshing(true);              urlLink = mEditText.getText().toString();          }            @Override          protected Boolean doInBackground(Void... voids) {              if (TextUtils.isEmpty(urlLink))                  return false;                try {                  if(!urlLink.startsWith("http://") && !urlLink.startsWith("https://"))                      urlLink = "http://" + urlLink;                    URL url = new URL(urlLink);                  InputStream inputStream = url.openConnection().getInputStream();                  mFeedModelList = parseFeed(inputStream);                  return true;              } catch (IOException e) {                  Log.e(TAG, "Error", e);              } catch (XmlPullParserException e) {                  Log.e(TAG, "Error", e);              }              return false;          }            @Override          protected void onPostExecute(Boolean success) {              mSwipeLayout.setRefreshing(false);                if (success) {                  mFeedTitleTextView.setText("Feed Title: " + mFeedTitle);                  mFeedDescriptionTextView.setText("Feed Description: " + mFeedDescription);                  mFeedLinkTextView.setText("Feed Link: " + mFeedLink);                  // Fill RecyclerView                  mRecyclerView.setAdapter(new RssFeedListAdapter(mFeedModelList));              } else {                  Toast.makeText(MainActivity.this,                          "Enter a valid Rss feed url",                          Toast.LENGTH_LONG).show();              }          }      }  

In the code snippet above, you can see that we only update the UI in onPreExecute and onPostExecute, while all the computation is done within doInBackground. We define FetchFeedTask as an inner class in MainActivity, so that we can access the MainActivity layout widgets.

In doInBackground, we first confirm that the url entered is not empty, then we add a 'http://' to the url if the user left it out. The next step is to open a url connection, using the url.getConnection().getInputStream() method. Finally, we call a method named parseFeed() to parse the resulting RSS feed.

Parsing the RSS feed

Thankfully, android contains some utility classes and interfaces to handle XML parsing. For our rss reader, we will use an XmlPullParser instance to handle parsing the feed. XmlPullParser can have either an InputStream or a Reader as the source of data. We simply read each XML tag in the RSS feed until we get to the end of the document. You can see in the code snippet below, that we are only interested in the XML tag if it is either title, description or link.

  public List<RssFeedModel> parseFeed(InputStream inputStream) throws XmlPullParserException,                                                                      IOException {          String title = null;          String link = null;          String description = null;          boolean isItem = false;          List<RssFeedModel> items = new ArrayList<>();            try {              XmlPullParser xmlPullParser = Xml.newPullParser();              xmlPullParser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false);              xmlPullParser.setInput(inputStream, null);                xmlPullParser.nextTag();              while (xmlPullParser.next() != XmlPullParser.END_DOCUMENT) {                  int eventType = xmlPullParser.getEventType();                    String name = xmlPullParser.getName();                  if(name == null)                      continue;                    if(eventType == XmlPullParser.END_TAG) {                      if(name.equalsIgnoreCase("item")) {                          isItem = false;                      }                      continue;                  }                    if (eventType == XmlPullParser.START_TAG) {                      if(name.equalsIgnoreCase("item")) {                          isItem = true;                          continue;                      }                  }                    Log.d("MyXmlParser", "Parsing name ==> " + name);                  String result = "";                  if (xmlPullParser.next() == XmlPullParser.TEXT) {                      result = xmlPullParser.getText();                      xmlPullParser.nextTag();                  }                    if (name.equalsIgnoreCase("title")) {                      title = result;                  } else if (name.equalsIgnoreCase("link")) {                      link = result;                  } else if (name.equalsIgnoreCase("description")) {                      description = result;                  }                    if (title != null && link != null && description != null) {                      if(isItem) {                          RssFeedModel item = new RssFeedModel(title, link, description);                          items.add(item);                      }                      else {                          mFeedTitle = title;                          mFeedLink = link;                          mFeedDescription = description;                      }                        title = null;                      link = null;                      description = null;                      isItem = false;                  }              }                return items;          } finally {              inputStream.close();          }      }  

RssFeedModel is a simple helper class we created to hold title, description and link information for an RSS feed item.

  public class RssFeedModel {        public String title;      public String link;      public String description;        public RssFeedModel(String title, String link, String description) {          this.title = title;          this.link = link;          this.description = description;      }  }  

Displaying the feeds

At this point, we are ready to fetch, and parse RSS feeds. However, we still need to display the results in our rss reader RecyclerView. Recall that in the onPostExecute() method above, there is the line:

  mRecyclerView.setAdapter(new RssFeedListAdapter(mFeedModelList));  

Once again, if you haven't used a RecyclerView before, check out our previous tutorial on Using RecyclerView. It is very easy and straightforward to use. To display each feed item, we create a layout file, called item_rss_feed.xml.

simple_rss_item_feed

simple_rss_item_feed
  <LinearLayout xmlns:android="http://ift.tt/nIICcg"      android:layout_width="match_parent"      android:layout_height="wrap_content"      android:orientation="vertical">        <TextView          android:id="@+id/titleText"          android:layout_width="match_parent"          android:layout_height="wrap_content"          android:textStyle="bold" />        <TextView          android:id="@+id/descriptionText"          android:layout_width="match_parent"          android:layout_height="wrap_content" />        <TextView          android:id="@+id/linkText"          android:layout_width="match_parent"          android:layout_height="wrap_content" />        <View          android:layout_width="match_parent"          android:layout_height="1dp"          android:background="@color/colorAccent" />  </LinearLayout>  

And finally, the RssFeedListAdapter.

  public class RssFeedListAdapter          extends RecyclerView.Adapter<RssFeedListAdapter.FeedModelViewHolder> {        private List<RssFeedModel> mRssFeedModels;        public static class FeedModelViewHolder extends RecyclerView.ViewHolder {          private View rssFeedView;            public FeedModelViewHolder(View v) {              super(v);              rssFeedView = v;          }      }        public RssFeedListAdapter(List<RssFeedModel> rssFeedModels) {          mRssFeedModels = rssFeedModels;      }        @Override      public FeedModelViewHolder onCreateViewHolder(ViewGroup parent, int type) {          View v = LayoutInflater.from(parent.getContext())                  .inflate(R.layout.item_rss_feed, parent, false);          FeedModelViewHolder holder = new FeedModelViewHolder(v);          return holder;      }        @Override      public void onBindViewHolder(FeedModelViewHolder holder, int position) {          final RssFeedModel rssFeedModel = mRssFeedModels.get(position);          ((TextView)holder.rssFeedView.findViewById(R.id.titleText)).setText(rssFeedModel.title);          ((TextView)holder.rssFeedView.findViewById(R.id.descriptionText))                                                               .setText(rssFeedModel.description);          ((TextView)holder.rssFeedView.findViewById(R.id.linkText)).setText(rssFeedModel.link);      }        @Override      public int getItemCount() {          return mRssFeedModels.size();      }  }  

simple_rss_just_xkcd

simple_rss_just_xkcd

Wrap up

As always, the complete source is available on github. You can look into styling your item_rss_feed.xml, displaying more content than just the item title, description and link, and/or, for the adventurous, writing your own RSS news aggreagator with multiple feeds from multiple sources.

Happy coding.



from Android Authority http://ift.tt/2giCUB0
via IFTTT