// Path: app/src/main/java/com/crazyhitty/chdev/ks/munch/models/SourceItem.java
// public class SourceItem {
//     private String sourceName, sourceUrl, sourceCategoryName, sourceDateAdded;
//     private int sourceCategoryImgId;
// 
//     public int getSourceCategoryImgId() {
//         return sourceCategoryImgId;
//     }
// 
//     public void setSourceCategoryImgId(int sourceCategoryImgId) {
//         this.sourceCategoryImgId = sourceCategoryImgId;
//     }
// 
//     public String getSourceName() {
//         return sourceName;
//     }
// 
//     public void setSourceName(String sourceName) {
//         this.sourceName = sourceName;
//     }
// 
//     public String getSourceUrl() {
//         return sourceUrl;
//     }
// 
//     public void setSourceUrl(String sourceUrl) {
//         this.sourceUrl = sourceUrl;
//     }
// 
//     public String getSourceDateAdded() {
//         return sourceDateAdded;
//     }
// 
//     public void setSourceDateAdded(String sourceDateAdded) {
//         this.sourceDateAdded = sourceDateAdded;
//     }
// 
//     public String getSourceCategoryName() {
//         return sourceCategoryName;
//     }
// 
//     public void setSourceCategoryName(String sourceCategoryName) {
//         this.sourceCategoryName = sourceCategoryName;
//     }
// }
// 
// Path: app/src/main/java/com/crazyhitty/chdev/ks/munch/utils/DateUtil.java
// public class DateUtil {
//     String formatRfc2822 = "EEE, dd MMM yyyy HH:mm:ss Z";
//     String formatLocal = "EEE, d MMM yyyy";
//     private String date;
// 
//     public String getCurrDate() {
//         date = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss").format(new Date());
//         return date;
//     }
// 
//     //converts rss publish date into a readable format
//     public String getDate(String pubDate) throws ParseException {
//         Date date = getDateObj(pubDate);
//         return new SimpleDateFormat(formatLocal).format(date);
//     }
// 
//     //get Date object from pub date
//     public Date getDateObj(String pubDate) throws ParseException {
//         SimpleDateFormat pubDateFormat = new SimpleDateFormat(formatRfc2822, Locale.ENGLISH); //rss spec
//         Date date = null;
//         try {
//             date = pubDateFormat.parse(pubDate);
//         } catch (ParseException e) {
//             pubDateFormat = new SimpleDateFormat(formatLocal); //fallback
//             date = pubDateFormat.parse(pubDate);
//         }
//         return date;
//     }
// }


import android.content.Context;
import android.os.AsyncTask;
import android.util.Log;
import android.webkit.MimeTypeMap;
import com.afollestad.materialdialogs.DialogAction;
import com.afollestad.materialdialogs.MaterialDialog;
import com.crazyhitty.chdev.ks.munch.R;
import com.crazyhitty.chdev.ks.munch.models.SourceItem;
import com.crazyhitty.chdev.ks.munch.utils.DateUtil;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.parser.Parser;
import org.jsoup.select.Elements;
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.List;
                    opmlDocument = Jsoup.connect(mUrl).parser(Parser.xmlParser()).get();
                } else {
                    opmlDocument = Jsoup.parse(mFile, "UTF-8");
                }
            } catch (IOException e) {
                e.printStackTrace();
                return e.getMessage();
            }
            if (opmlDocument != null) {
                mOpmlItems = opmlDocument.select("outline");
            }
            return "success";
        }

        @Override
        protected void onPostExecute(String s) {
            super.onPostExecute(s);
            mLoadingDialog.dismiss();
            if (s.equals("success")) {
                Log.e("Opml Items", String.valueOf(mOpmlItems.size()));
                List<SourceItem> sourceItems = new ArrayList<>();
                for (Element opmlItem : mOpmlItems) {
                    String title = opmlItem.attr("text");
                    String url = null;
                    if (!opmlItem.attr("xmlUrl").isEmpty()) {
                        url = opmlItem.attr("xmlUrl");
                    } else if (opmlItem.attr("url").isEmpty()) {
                        url = opmlItem.attr("url");
                    }
                    if (url != null) {
// Path: app/src/main/java/com/crazyhitty/chdev/ks/munch/models/SourceItem.java
// public class SourceItem {
//     private String sourceName, sourceUrl, sourceCategoryName, sourceDateAdded;
//     private int sourceCategoryImgId;
// 
//     public int getSourceCategoryImgId() {
//         return sourceCategoryImgId;
//     }
// 
//     public void setSourceCategoryImgId(int sourceCategoryImgId) {
//         this.sourceCategoryImgId = sourceCategoryImgId;
//     }
// 
//     public String getSourceName() {
//         return sourceName;
//     }
// 
//     public void setSourceName(String sourceName) {
//         this.sourceName = sourceName;
//     }
// 
//     public String getSourceUrl() {
//         return sourceUrl;
//     }
// 
//     public void setSourceUrl(String sourceUrl) {
//         this.sourceUrl = sourceUrl;
//     }
// 
//     public String getSourceDateAdded() {
//         return sourceDateAdded;
//     }
// 
//     public void setSourceDateAdded(String sourceDateAdded) {
//         this.sourceDateAdded = sourceDateAdded;
//     }
// 
//     public String getSourceCategoryName() {
//         return sourceCategoryName;
//     }
// 
//     public void setSourceCategoryName(String sourceCategoryName) {
//         this.sourceCategoryName = sourceCategoryName;
//     }
// }
// 
// Path: app/src/main/java/com/crazyhitty/chdev/ks/munch/utils/DateUtil.java
// public class DateUtil {
//     String formatRfc2822 = "EEE, dd MMM yyyy HH:mm:ss Z";
//     String formatLocal = "EEE, d MMM yyyy";
//     private String date;
// 
//     public String getCurrDate() {
//         date = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss").format(new Date());
//         return date;
//     }
// 
//     //converts rss publish date into a readable format
//     public String getDate(String pubDate) throws ParseException {
//         Date date = getDateObj(pubDate);
//         return new SimpleDateFormat(formatLocal).format(date);
//     }
// 
//     //get Date object from pub date
//     public Date getDateObj(String pubDate) throws ParseException {
//         SimpleDateFormat pubDateFormat = new SimpleDateFormat(formatRfc2822, Locale.ENGLISH); //rss spec
//         Date date = null;
//         try {
//             date = pubDateFormat.parse(pubDate);
//         } catch (ParseException e) {
//             pubDateFormat = new SimpleDateFormat(formatLocal); //fallback
//             date = pubDateFormat.parse(pubDate);
//         }
//         return date;
//     }
// }


// Path: app/src/main/java/com/crazyhitty/chdev/ks/munch/importopml/ImportOpmlInteractor.java
import android.content.Context;
import android.os.AsyncTask;
import android.util.Log;
import android.webkit.MimeTypeMap;
import com.afollestad.materialdialogs.DialogAction;
import com.afollestad.materialdialogs.MaterialDialog;
import com.crazyhitty.chdev.ks.munch.R;
import com.crazyhitty.chdev.ks.munch.models.SourceItem;
import com.crazyhitty.chdev.ks.munch.utils.DateUtil;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.parser.Parser;
import org.jsoup.select.Elements;
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.List;

                    opmlDocument = Jsoup.connect(mUrl).parser(Parser.xmlParser()).get();
                } else {
                    opmlDocument = Jsoup.parse(mFile, "UTF-8");
                }
            } catch (IOException e) {
                e.printStackTrace();
                return e.getMessage();
            }
            if (opmlDocument != null) {
                mOpmlItems = opmlDocument.select("outline");
            }
            return "success";
        }

        @Override
        protected void onPostExecute(String s) {
            super.onPostExecute(s);
            mLoadingDialog.dismiss();
            if (s.equals("success")) {
                Log.e("Opml Items", String.valueOf(mOpmlItems.size()));
                List<SourceItem> sourceItems = new ArrayList<>();
                for (Element opmlItem : mOpmlItems) {
                    String title = opmlItem.attr("text");
                    String url = null;
                    if (!opmlItem.attr("xmlUrl").isEmpty()) {
                        url = opmlItem.attr("xmlUrl");
                    } else if (opmlItem.attr("url").isEmpty()) {
                        url = opmlItem.attr("url");
                    }
                    if (url != null) {
                        SourceItem sourceItem = new SourceItem();