Hot File

CPDroid (CodeProject on Fly !!)

View: 926    Dowload: 0   Comment: 0   Post by: sonbka04  
Author: none   Category: Android   Fields: Computers - Technology

0 point/3 review File has been tested

Download   cpdroid-codeproject-on-fly.zip (69.53 KB)

You need to Sign In to download the file cpdroid-codeproject-on-fly.zip
If you do not have an account then Sign up for free here

Download error   Report copyright violation

before starting my article, at the outset I would like to say that I am very addicted to reading articles on CodeProject. Also, I am a small contributor in this community and have given a couple of articles to it. I try to read almost all good articles in this community. Sometimes, I found that I have time but I don’t have my laptop to browse article (usually on long drive to my native place), so I surf CodeProject site in my mobile browser, which is not attractive. So in the process of solving my problem, I decided to make a native app for CodeProject and finally I developed an application which is known as “CPDroid” in the Android market. I would like to thank Luc Pattyn for his beautiful effort in CPVanity tool for CodeProject as I get most of the ideas from his article for CPDroid. You can install it from Android market here.

Introduction

 

Anyway let’s start a little introduction for CPDroid. CPDroid is a native application for Android based mobile phone. I divided the application component in three parts.

  1. The first part consists of author search on the basis of their CodeProject member id. It will fetch author information and respective data in a neat and clean format.
  2. The second part gives latest feed of CodeProject articles and tips.
  3. The third part is just about me ? and license.

CPDroid Functionality

Functionality of CPDroid is very simple and straightforward. Let us summarize it as:

  • Search result of author is very handy and attractive. User will get author information with their respective points and other details like number of articles, messages, etc. along with list of articles and reputation graph.
  • User can read every article on click of listview and it will open article in best readable format of webview.
  • Get latest feed of CodeProject articles using Android SAX parser technique.

Main UI

Main user interface is navigator for different parts. This is Android activity which calls three different component buttons. Intent is used to fire associated activity for search author and latest feeds. Because Main UI consists of simple functionality, then I would not go too much in this section and it is better to give how I made rounded buttons in UI for navigation to section.

<?xml version="1.0" encoding="utf-8"?>
<selector
    xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_pressed="true" >
     <bitmap android:src="@drawable/btnsearchall_pressed"
        android:gravity="center" />        
    </item> 
     <item android:state_enabled="true" >
     <bitmap android:src="@drawable/btnsearchall"
        android:gravity="center" />        
    </item>
</selector>

In Android, we can highlight the button through custom images. To indicate the different button states (focused, selected, etc.), you can define a different image for each state. E.g., a blue image by default, an orange one for when focused, and a yellow one for when pressed. An easy way to do this is with an XML drawable "selector." In this code, when button is pressed, it will call drawable source image button pressed and when it is not, it will call different drawable. UI is simply delegated by the Android operating system by mapping it elegantly. And this is the beauty of Android OS which attracts me to jump in Android.

Search Author

This is my favourite section and USP of CPDroid. User can perform search author with respective member Id. Though it is very tough to search author with id instead of name, I can’t put in more effort on custom URL and complex Regex operation to get required data of author. Actually life is easy if CodeProject would have any web service for this. Every data is coming from parsed HTML which I must say it is not good for a stable application. And this is the big fear of application for down as well. Anyway, I hope CodeProject will provide some web service in future to extend the community.

Anyway Search author result is separately handled by the model and parsing of HTML is handled by thread which delivers to view by Handler class. A Handler allows you to send and process Message and Runnable objects associated with a thread's MessageQueue. Each Handler instance is associated with a single thread and that thread's message queue. When you create a new Handler, it is bound to the thread / message queue of the thread that is creating it -- from that point on, it will deliver messages and runnables to that message queue and execute them as they come out of the message queue.

There are two main uses for a Handler:

  1. To schedule messages and runnables to be executed as some point in the future; and
  2. To enqueue an action to be performed on a different thread than your own.
 
public void GetCpAuthorSummary(final ICPAuthorSummary cpAuthorNameCallback) {
    new Thread(new Runnable() {

        @Override
        public void run() {

            try {
                 summaryList = cp.GetAuthorSummary();
                 cp.GetArticlePage();
                 authorName = cp.GetName();
                 handler.post(new Runnable() {
                    @Override
                    public void run() {
                    cpAuthorNameCallback.AuthorSummaryResult
                        (true, authorName, summaryList);
                    }
                });
            } catch (Exception ex) {
                cpAuthorNameCallback.AuthorSummaryResult(false,
                    authorName, summaryList);
            }
        }
    }).start();
}

Here, I used Interface ICPAuthorSummary for getting results from thread and further implement interface in Search author Activity. Boolean result of Interface ensures when to publish data in view.

Image Viewer

Once search is performed, it will gives Author CodeProject profile Image with other relative details. For image viewer, I used to download image from URL which extracts image from application context and HTML, then downloads to stream and generates Drawable Image source.

 
public Drawable ImageOperations(Context ctx, String url, String saveFilename) {
    try {
        InputStream is = (InputStream) this.fetch(url);
        Drawable d = Drawable.createFromStream(is, "src");
        return d;
    } catch (MalformedURLException e) {
        e.printStackTrace();
        return null;
    } catch (IOException e) {
        e.printStackTrace();
        return null;
    }
}

public Object fetch(String address) throws MalformedURLException,IOException {
    URL url = new URL(address);
    Object content = url.getContent();
    return content;
}

Author Stats, Articles and Reputation

This section will have three tabs associated with it. First tab “Stats” gives listView of stats of articles. Here, I put in more effort to get regular expression for stats.

Articles will gives article for respective searched author. All articles will be published with their article details like View, Bookmark, votes, Popularity and Ratings. You can directly click on any article and read it in webview. Reputation is not very attractive, it just gives the reputation graph.

PID5

Latest Article Feed

For this section, thanks God!! CodeProject gives RSS feed for latest article. So I used Android SAX parser to get feed in view. I’m not going to give details on Android SAX parser because for this, it must be covered in a full phase article which I will surely give you in a separate effort of an article thread.

Conclusion

CPDroid is a simple, attractive and easy to use native application in Android. However, I did not implement a lot of functionality in the application because of absence of CodeProject Web service. It’s really hard to parse HTML content and get data using complex regular expression. But if this application becomes popular, I will defiantly release next version of CPDroid.

Future Component

The future idea of few components is running in mind to add more functionality in CPDroid. But I would like to release it in the next version if application will give good response from Android market. Some components are below:

  • Bookmark functionality to bookmark favorite author
  • Save article in PDF
  • Menu Control navigator
  • Show Famous Author Awards

History

  • Release Version: 1.0

CPDroid (CodeProject on Fly !!)

CPDroid (CodeProject on Fly !!) Posted on 25-03-2014  before starting my article, at the outset I would like to say that I am very addicted to reading articles on CodeProject. Also, I am a small contributor in this community and have given a couple of articles to it. I try to read almost all good articles in this community. Sometimes, I found that I have time but I don’t have my laptop to browse article (usually on long drive to my native place), so I surf CodeProject site in my mobile browser, which is not attractive. So in the process of solving my problem, I decided to make a native app for CodeProject and finally I developed an application which is known as “CPDroid” in the Android market. I would like to thank Luc Pattyn for his beautiful effort in CPVanity tool for CodeProject as I get most of the ideas from his article for CPDroid. You can install it from Android market here. 5/10 926

Comment:

To comment you must be logged in members.

Files with category

  • How to Monetizing Apps with the Google AdMob SDK

    View: 433    Download: 0   Comment: 0   Author: none  

    How to Monetizing Apps with the Google AdMob SDK

    Category: Android
    Fields: Other

    4.75/2 review
    AdMob is a mobile advertising platform from Google that developers can use to generate revenue from apps through in-app advertising. AdMob provides different sets of ads like banner ads, interstitial ads, video ads, or native ads integrated with...

  • How to Securing Your Android Apps with the Fingerprint API

    View: 362    Download: 0   Comment: 0   Author: none  

    How to Securing Your Android Apps with the Fingerprint API

    Category: Android
    Fields: Other

    5/1 review
    Passwords have had their day, with software vendors and hardware manufacturers encouraging users to try other methods of securing their data. Fingerprint readers are becoming more common on Android devices since Marshmallow introduced a new...

  • Transfer Data between Activities with Android Parcelable with android

    View: 781    Download: 0   Comment: 0   Author: none  

    Transfer Data between Activities with Android Parcelable with android

    Category: Android
    Fields: Other

    0/0 review
    An Android app typically consists of more than one activity that need to pass data between each other. For example a primary activity with a list of elements and a corresponding secondary activity to show the details of these elements

  • Optimize Your Java Code with Android Butter Knife

    View: 525    Download: 0   Comment: 0   Author: none  

    Optimize Your Java Code with Android Butter Knife

    Category: Android
    Fields: Other

    1.5/3 review
    Creating code can sometimes be frustrating. Developers have to deal with redundant coding that is visually unattractive.

  • How to Use React Native to a Create a Face Recognition App

    View: 487    Download: 0   Comment: 0   Author: none  

    How to Use React Native to a Create a Face Recognition App

    Category: Android
    Fields: Other

    2.25/2 review
    nce you have signed up for an account, login and click on the search icon at the top of the screen and search for ‘cognitive services’. From the dropdown that shows, click on Cognitive Services accounts (preview) and you should see the following...

  • How to Authenticating Users via OAuth with Cordova and Ionic

    View: 246    Download: 0   Comment: 0   Author: none  

    How to Authenticating Users via OAuth with Cordova and Ionic

    Category: Android
    Fields: Other

    0/0 review
    You will need to install Cordova (I recommend SitePoint’s QuickTip) and the Ionic framework (again, I recommend SitePoint’s QuickTip)

  • Make Access Platform APIs with React Native Modules

    View: 22107    Download: 0   Comment: 0   Author: none  

    Make Access Platform APIs with React Native Modules

    Category: Android
    Fields: Other

    4.5/1 review
    SitePoint has a full guide for installing React Native available here. Once it’s installed, create a new project with the following command

  • Build Animating an Android Floating Action Button

    View: 484    Download: 0   Comment: 0   Author: none  

    Build Animating an Android Floating Action Button

    Category: Android
    Fields: Other

    4.5/1 review
    The Floating Action Button looks something like this in a layout file and will be auto generated if create an Android Studio project with a Blank Activity:

 
Newsletter Email

File suggestion for you

File top downloads

logo codetitle
Codetitle.com - library source code to share, download the file to the community
Copyright © 2015. All rights reserved. codetitle.com Develope by Vinagon .Ltd