Android Open Source - Crowdsource Reddit Post






From Project

Back to project page Crowdsource.

License

The source code is released under:

Apache License

If you think the Android project Crowdsource listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/**
 *//from w  w  w .j  a  v  a2s .c  o m
 * Copyright 2014 Cody Huzarski (chuzarski.net)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 *
 */

package net.chuzarski.crowdednews.utils.reddit;


import java.util.Date;

/**
 * This class will encapsulate the data that is a single Reddit post
 */

public class RedditPost {

    private String title;
    private String linkURL;
    private String redditName;
    private String redditId;
    private String linkDomain;
    private boolean isStickied;
    private long createdTimeUTC;

    public static class Builder {

        //highly required
        private final String title;
        private final String linkURL;
        //currently optional
        private String redditName;
        private String linkDomain;

        private String redditId;
        private boolean isStickied;
        private long createdTimeUTC;

        public Builder(String title, String link) {
            this.title = title;
            this.linkURL = link;
        }

        //remaining setters
        public Builder redditName(String name) { this.redditName = name; return this; }
        public Builder redditId(String id) {this.redditId = id; return this;}
        public Builder isStickied(boolean sticky) {this.isStickied = sticky; return this; }
        public Builder timeCreated(long time) {this.createdTimeUTC = time; return this;}
        public Builder linkDomain(String d) { this.linkDomain = d; return this;}

        //builder!
        public RedditPost build() {
            return new RedditPost(this);
        }

    }

    private RedditPost(Builder b) {
        this.setTitle(b.title);
        this.setLinkURL(b.linkURL);
        this.setRedditName(b.redditName);
        this.setRedditId(b.redditId);
        this.setStickied(b.isStickied);
        this.setCreatedTimeUTC(b.createdTimeUTC);
        this.setLinkDomain(b.linkDomain);
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getLinkURL() {
        return linkURL;
    }

    public void setLinkURL(String linkURL) {
        this.linkURL = linkURL;
    }

    public String getRedditName() {
        return redditName;
    }

    public void setRedditName(String redditName) {
        this.redditName = redditName;
    }

    public String getRedditId() {
        return redditId;
    }

    public void setRedditId(String redditId) {
        this.redditId = redditId;
    }

    public boolean isStickied() {
        return isStickied;
    }

    public void setStickied(boolean isStickied) {
        this.isStickied = isStickied;
    }

    public long getCreatedTimeUTC() {
        return createdTimeUTC;
    }

    public void setCreatedTimeUTC(long createdTimeUTC) {
        this.createdTimeUTC = createdTimeUTC;
    }

    public void setLinkDomain(String d) { this.linkDomain = d;}

    public String getLinkDomain() {return linkDomain;}

    public Date getCreatedDate() {

        //TODO This dirty workaround needs to somehow be replaced, but Reddit is broke.
        //The reddit created_utc timestamp is INVALID
        //(go ahead, test it http://currentmillis.com/
        //it for some reason shaves three digits off of the real time.
        //this for now will return a round-about date
        return new Date(Long.parseLong(Long.toString(createdTimeUTC) + "000"));
    }


}




Java Source Code List

net.chuzarski.crowdednews.ApplicationTest.java
net.chuzarski.crowdednews.CrowdedNewsApplication.java
net.chuzarski.crowdednews.activities.ArticleViewActivity.java
net.chuzarski.crowdednews.activities.LicenseActivity.java
net.chuzarski.crowdednews.activities.MainActivity.java
net.chuzarski.crowdednews.activities.SettingsActivity.java
net.chuzarski.crowdednews.adapters.PostsAdapter.java
net.chuzarski.crowdednews.events.ArticleLoadCompleteEvent.java
net.chuzarski.crowdednews.events.RedditRetrieveCompletedEvent.java
net.chuzarski.crowdednews.jobs.RedditRetrieveJob.java
net.chuzarski.crowdednews.jobs.util.RedditJobParams.java
net.chuzarski.crowdednews.utils.AppSession.java
net.chuzarski.crowdednews.utils.ProductionTree.java
net.chuzarski.crowdednews.utils.RedditSources.java
net.chuzarski.crowdednews.utils.reddit.RedditErrors.java
net.chuzarski.crowdednews.utils.reddit.RedditException.java
net.chuzarski.crowdednews.utils.reddit.RedditPost.java
net.chuzarski.crowdednews.utils.reddit.RedditRequest.java
net.chuzarski.crowdednews.utils.reddit.RedditResponse.java