Android Open Source - Gazetti_Newspaper_Reader Config Service






From Project

Back to project page Gazetti_Newspaper_Reader.

License

The source code is released under:

MIT License

If you think the Android project Gazetti_Newspaper_Reader 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

package in.sahildave.gazetti.util;
/*from   www .  j  av a2  s. com*/
import com.parse.ParseConfig;

/**
 * Created by sahil on 3/10/14.
 */
public class ConfigService {

    private static ConfigService _instance;

    private ConfigService() {
        if (isConfigAvailable()) {
            ParseConfig config = ParseConfig.getCurrentConfig();
            setConfigVersion(config.getNumber("version"));
            setTheHinduElementsFromConfig(config);
            setTOIElementsFromConfig(config);
            setIndianExpressElementsFromConfig(config);
            setFirstPostElementsFromConfig(config);
        } else {
            setTheHinduElementsFromConstants();
            setTOIElementsFromConstants();
            setIndianExpressElementsFromConstants();
            setFirstPostElementsFromConstants();
        }
    }
    public static synchronized ConfigService getInstance(){
        if (_instance == null) {
            _instance = new ConfigService();
        }
        return _instance;
    }

    public void destroyConfigService(){
        _instance = null;
    }
    
    private boolean isConfigAvailable() {
        return (ParseConfig.getCurrentConfig() != null);
    }

    private Number configVersion;

    public Number getConfigVersion() {
        return configVersion;
    }

    public void setConfigVersion(Number configVersion) {
        this.configVersion = configVersion;
    }

    /*
        THE HINDU
     */

    private void setTheHinduElementsFromConstants() {
        setTheHinduBody(Constants.th_body);
        setTheHinduHead(Constants.th_head);
        setTheHinduImageFirst(Constants.th_image_1);
        setTheHinduImageSecond(Constants.th_image_2);
    }

    private void setTheHinduElementsFromConfig(ParseConfig config) {
        setTheHinduBody(config.getString("th_body"));
        setTheHinduHead(config.getString("th_head"));
        setTheHinduImageFirst(config.getString("th_image_1"));
        setTheHinduImageSecond(config.getString("th_image_2"));
    }

    private String theHinduBody;
    private String theHinduHead;
    private String theHinduImageFirst;
    private String theHinduImageSecond;

    public String getTheHinduBody() {
        return theHinduBody;
    }

    public void setTheHinduBody(String theHinduBody) {
        this.theHinduBody = theHinduBody;
    }

    public String getTheHinduHead() {
        return theHinduHead;
    }

    public void setTheHinduHead(String theHinduHead) {
        this.theHinduHead = theHinduHead;
    }

    public String getTheHinduImageFirst() {
        return theHinduImageFirst;
    }

    public void setTheHinduImageFirst(String theHinduImageFirst) {
        this.theHinduImageFirst = theHinduImageFirst;
    }

    public String getTheHinduImageSecond() {
        return theHinduImageSecond;
    }

    public void setTheHinduImageSecond(String theHinduImageSecond) {
        this.theHinduImageSecond = theHinduImageSecond;
    }

     /*
        THE TIMES OF INDIA
     */

    private void setTOIElementsFromConstants() {
        setTOIBody(Constants.toi_body);
        setTOIHead(Constants.toi_head);
        setTOIImageFirst(Constants.toi_image_1);
        setTOIImageSecond(Constants.toi_image_2);
    }

    private void setTOIElementsFromConfig(ParseConfig config) {
        setTOIBody(config.getString("toi_body"));
        setTOIHead(config.getString("toi_head"));
        setTOIImageFirst(config.getString("toi_image_1"));
        setTOIImageSecond(config.getString("toi_image_2"));
    }

    private String toiBody;
    private String toiHead;
    private String toiImageFirst;
    private String toiImageSecond;

    public String getTOIBody() {
        return toiBody;
    }

    public void setTOIBody(String toiBody) {
        this.toiBody = toiBody;
    }

    public String getTOIHead() {
        return toiHead;
    }

    public void setTOIHead(String toiHead) {
        this.toiHead = toiHead;
    }

    public String getTOIImageFirst() {
        return toiImageFirst;
    }

    public void setTOIImageFirst(String toiImageFirst) {
        this.toiImageFirst = toiImageFirst;
    }

    public String getTOIImageSecond() {
        return toiImageSecond;
    }

    public void setTOIImageSecond(String toiImageSecond) {
        this.toiImageSecond = toiImageSecond;
    }
    
     /*
        THE INDIAN EXPRESS
     */

    private void setIndianExpressElementsFromConstants() {
        setIndianExpressBody(Constants.tie_body);
        setIndianExpressHead(Constants.tie_head);
        setIndianExpressImage(Constants.tie_image);

        setIndianExpressBusinessBody(Constants.tie_business_body);
        setIndianExpressBusinessHead(Constants.tie_business_head);
        setIndianExpressBusinessImage(Constants.tie_business_image);
    }

    private void setIndianExpressElementsFromConfig(ParseConfig config) {
        setIndianExpressBody(config.getString("tie_body"));
        setIndianExpressHead(config.getString("tie_head"));
        setIndianExpressImage(config.getString("tie_image"));

        setIndianExpressBusinessBody(config.getString("tie_business_body"));
        setIndianExpressBusinessHead(config.getString("tie_business_head"));
        setIndianExpressBusinessImage(config.getString("tie_business_image"));
    }

    private String tieBody;
    private String tieHead;
    private String tieImage;
    private String tieBusinessBody;
    private String tieBusinessHead;
    private String tieBusinessImage;

    public String getIndianExpressBody() {
        return tieBody;
    }

    public void setIndianExpressBody(String tieBody) {
        this.tieBody = tieBody;
    }

    public String getIndianExpressHead() {
        return tieHead;
    }

    public void setIndianExpressHead(String tieHead) {
        this.tieHead = tieHead;
    }

    public String getIndianExpressImage() {
        return tieImage;
    }

    public void setIndianExpressImage(String tieImage) {
        this.tieImage = tieImage;
    }

    public String getIndianExpressBusinessImage() {
        return tieBusinessImage;
    }

    public void setIndianExpressBusinessImage(String tieBusinessImage) {
        this.tieBusinessImage = tieBusinessImage;
    }

    public String getIndianExpressBusinessBody() {
        return tieBusinessBody;
    }

    public void setIndianExpressBusinessBody(String tieBusinessBody) {
        this.tieBusinessBody = tieBusinessBody;
    }

    public String getIndianExpressBusinessHead() {
        return tieBusinessHead;
    }

    public void setIndianExpressBusinessHead(String tieBusinessHead) {
        this.tieBusinessHead = tieBusinessHead;
    }

    /*
        FIRSTPOST
    */

    private void setFirstPostElementsFromConstants() {
        setFirstPostBody(Constants.fp_body);
        setFirstPostHead(Constants.fp_head);
        setFirstPostImage(Constants.fp_image);
    }

    private void setFirstPostElementsFromConfig(ParseConfig config) {
        setFirstPostBody(config.getString("fp_body"));
        setFirstPostHead(config.getString("fp_head"));
        setFirstPostImage(config.getString("fp_image"));
    }

    private String fpBody;
    private String fpHead;
    private String fpImage;

    public String getFirstPostBody() {
        return fpBody;
    }

    public void setFirstPostBody(String fpBody) {
        this.fpBody = fpBody;
    }

    public String getFirstPostHead() {
        return fpHead;
    }

    public void setFirstPostHead(String fpHead) {
        this.fpHead = fpHead;
    }

    public String getFirstPostImage() {
        return fpImage;
    }

    public void setFirstPostImage(String fpImage) {
        this.fpImage = fpImage;
    }
}




Java Source Code List

in.sahildave.gazetti.StarterApplication.java
in.sahildave.gazetti.bookmarks.BookmarkAdapter.java
in.sahildave.gazetti.bookmarks.BookmarkDetailActivity.java
in.sahildave.gazetti.bookmarks.BookmarkDetailFragment.java
in.sahildave.gazetti.bookmarks.BookmarkListActivity.java
in.sahildave.gazetti.bookmarks.BookmarkListFragment.java
in.sahildave.gazetti.bookmarks.BookmarkLoadingCallback.java
in.sahildave.gazetti.bookmarks.sqlite.BookmarkDataSource.java
in.sahildave.gazetti.bookmarks.sqlite.BookmarkModel.java
in.sahildave.gazetti.bookmarks.sqlite.SQLiteHelper.java
in.sahildave.gazetti.homescreen.HomeScreenActivity.java
in.sahildave.gazetti.homescreen.HomeScreenFragment.java
in.sahildave.gazetti.homescreen.adapter.AddCellDialogFragment.java
in.sahildave.gazetti.homescreen.adapter.CellModel.java
in.sahildave.gazetti.homescreen.adapter.EditCellDialogFragment.java
in.sahildave.gazetti.homescreen.adapter.GridAdapter.java
in.sahildave.gazetti.homescreen.adapter.NewsCatModel.java
in.sahildave.gazetti.homescreen.newcontent.DialogNewContentExpListAdaper.java
in.sahildave.gazetti.homescreen.newcontent.DialogNewContent.java
in.sahildave.gazetti.news_activities.ArticleLoadingCallback.java
in.sahildave.gazetti.news_activities.WebViewFragment.java
in.sahildave.gazetti.news_activities.WebsiteDetailActivity.java
in.sahildave.gazetti.news_activities.WebsiteDetailFragment.java
in.sahildave.gazetti.news_activities.WebsiteListActivity.java
in.sahildave.gazetti.news_activities.WebsiteListFragment.java
in.sahildave.gazetti.news_activities.adapter.NavDrawerListAdapter.java
in.sahildave.gazetti.news_activities.adapter.NewsAdapter.java
in.sahildave.gazetti.news_activities.adapter.RobotoLight.java
in.sahildave.gazetti.news_activities.fetch.firstPost.java
in.sahildave.gazetti.news_activities.fetch.hindu.java
in.sahildave.gazetti.news_activities.fetch.indianExpressBusiness.java
in.sahildave.gazetti.news_activities.fetch.indianExpress.java
in.sahildave.gazetti.news_activities.fetch.toi.java
in.sahildave.gazetti.preference.FeedSelectFragment.java
in.sahildave.gazetti.preference.FeedSelectSettingsActivity.java
in.sahildave.gazetti.preference.LicensesActivity.java
in.sahildave.gazetti.preference.PreferenceExpListAdapter.java
in.sahildave.gazetti.preference.SettingsActivity.java
in.sahildave.gazetti.util.BitmapTransform.java
in.sahildave.gazetti.util.ConfigService.java
in.sahildave.gazetti.util.Constants.java
in.sahildave.gazetti.util.GazettiEnums.java
in.sahildave.gazetti.util.JsonHelper.java
in.sahildave.gazetti.util.NewsCatFileUtil.java
in.sahildave.gazetti.util.ShareButtonListener.java
in.sahildave.gazetti.util.UserPrefUtil.java
in.sahildave.gazetti.welcomescreen.WelcomeScreenExpListAdapter.java
in.sahildave.gazetti.welcomescreen.WelcomeScreenFragmentExpList.java
in.sahildave.gazetti.welcomescreen.WelcomeScreenFragmentFirst.java
in.sahildave.gazetti.welcomescreen.WelcomeScreenViewPagerActivity.java