Search in sources :

Example 6 with FileMeta

use of com.foobnix.dao2.FileMeta in project LibreraReader by foobnix.

the class StackRemoteViewsFactory method getViewAt.

@Override
public RemoteViews getViewAt(int position) {
    RemoteViews v = new RemoteViews(context.getPackageName(), R.layout.widget_grid_image);
    if (recent.size() <= position) {
        return v;
    }
    FileMeta uri = recent.get(position);
    String url = IMG.toUrl(uri.getPath(), ImageExtractor.COVER_PAGE_WITH_EFFECT, IMG.getImageSize());
    Bitmap image = ImageLoader.getInstance().loadImageSync(url, IMG.displayCacheMemoryDisc);
    v.setImageViewBitmap(R.id.imageView1, image);
    v.setContentDescription(R.id.imageView1, new File(uri.getPath()).getName());
    Bundle extras = new Bundle();
    extras.putInt("pos", position);
    extras.putParcelable("uri", Uri.fromFile(new File(uri.getPath())));
    Intent fillInIntent = new Intent();
    fillInIntent.putExtras(extras);
    v.setOnClickFillInIntent(R.id.imageView1, fillInIntent);
    return v;
}
Also used : RemoteViews(android.widget.RemoteViews) Bitmap(android.graphics.Bitmap) Bundle(android.os.Bundle) Intent(android.content.Intent) File(java.io.File) FileMeta(com.foobnix.dao2.FileMeta)

Example 7 with FileMeta

use of com.foobnix.dao2.FileMeta in project LibreraReader by foobnix.

the class HorizontalModeController method init.

public void init(final Activity activity) {
    PageImageState.get().cleanSelectedWords();
    PageImageState.get().pagesText.clear();
    LOG.d("DocumentControllerHorizontalView", "init begin");
    bookPath = getBookPathFromActivity(activity);
    AppState.get().lastBookPath = bookPath;
    BookSettings bs = SettingsManager.getBookSettings(bookPath);
    if (bs != null) {
        AppState.get().isCut = bs.splitPages;
        AppState.get().isCrop = bs.cropPages;
        AppState.get().isDouble = bs.doublePages;
        AppState.get().isDoubleCoverAlone = bs.doublePagesCover;
        AppState.get().isLocked = bs.isLocked;
        TempHolder.get().pageDelta = bs.pageDelta;
        if (AppState.get().isCropPDF && !isTextFormat) {
            AppState.get().isCrop = true;
        }
    }
    BookCSS.get().detectLang(bookPath);
    if (false) {
        PageImageState.get().needAutoFit = true;
    } else {
        if (TxtUtils.isNotEmpty(bookPath) && !ExtUtils.isTextFomat(bookPath)) {
            String string = matrixSP.getString(bookPath.hashCode() + "", "");
            LOG.d("MATRIX", "READ STR", string);
            if (TxtUtils.isEmpty(string) || AppState.get().isCut || AppState.get().isCrop) {
                PageImageState.get().needAutoFit = true;
            } else {
                PageImageState.get().needAutoFit = false;
            }
            Matrix matrix = PageImageState.fromString(string);
            PageImageState.get().getMatrix().set(matrix);
            LOG.d("MATRIX", "READ", bookPath.hashCode() + "", PageImageState.get().getMatrixAsString());
        }
    }
    if (AppState.get().isDouble && isTextFormat) {
        imageWidth = Dips.screenWidth() / 2;
    }
    FileMetaCore.checkOrCreateMetaInfo(activity);
    LOG.d("pagesCount", "init", imageWidth, imageHeight);
    String pasw = activity.getIntent().getStringExtra(EXTRA_PASSWORD);
    pasw = TxtUtils.nullToEmpty(pasw);
    codeDocument = ImageExtractor.getNewCodecContext(getBookPath(), pasw, imageWidth, imageHeight);
    if (codeDocument != null) {
        pagesCount = codeDocument.getPageCount();
    } else {
        pagesCount = 0;
    }
    if (pagesCount == -1) {
        throw new IllegalArgumentException("Pages count = -1");
    }
    try {
        if (pagesCount > 0) {
            FileMeta meta = AppDB.get().load(bs.fileName);
            if (meta != null) {
                meta.setPages(pagesCount);
                AppDB.get().update(meta);
            }
        }
    } catch (Exception e) {
        LOG.e(e);
    }
    // int charsCount = 0;
    // for (int i = 0; i <= pagesCount; i++) {
    // CodecPage page2 = codeDocument.getPage(i);
    // charsCount += page2.getCharCount();
    // page2.recycle();
    // }
    // LOG.d("total-chars", charsCount);
    AppDB.get().addRecent(bookPath);
    getPageFromUri();
// loadOutline(null);
}
Also used : Matrix(android.graphics.Matrix) BookSettings(org.ebookdroid.common.settings.books.BookSettings) FileMeta(com.foobnix.dao2.FileMeta)

Example 8 with FileMeta

use of com.foobnix.dao2.FileMeta in project LibreraReader by foobnix.

the class StarsFragment2 method prepareDataInBackground.

@Override
public List<FileMeta> prepareDataInBackground() {
    List<FileMeta> all = new ArrayList<FileMeta>();
    List<String> tags = AppDB.get().getAll(SEARCH_IN.TAGS);
    if (TxtUtils.isListNotEmpty(tags)) {
        for (String tag : tags) {
            FileMeta m = new FileMeta("");
            m.setCusType(FileMetaAdapter.DISPALY_TYPE_LAYOUT_TAG);
            int count = AppDB.get().getAllWithTag(tag).size();
            m.setPathTxt(tag + " (" + count + ")");
            all.add(m);
        }
        FileMeta empy = new FileMeta();
        empy.setCusType(FileMetaAdapter.DISPALY_TYPE_LAYOUT_TITLE_NONE);
        all.add(empy);
    }
    all.addAll(AppDB.get().getStarsFolder());
    FileMeta books = new FileMeta();
    books.setCusType(FileMetaAdapter.DISPALY_TYPE_LAYOUT_TITLE_NONE);
    all.add(books);
    all.addAll(AppDB.get().getStarsFiles());
    return all;
}
Also used : ArrayList(java.util.ArrayList) FileMeta(com.foobnix.dao2.FileMeta)

Example 9 with FileMeta

use of com.foobnix.dao2.FileMeta in project LibreraReader by foobnix.

the class FileMetaCore method checkOrCreateMetaInfo.

public static void checkOrCreateMetaInfo(Activity a) {
    try {
        String path = CacheManager.getFilePathFromAttachmentIfNeed(a);
        if (!BookType.isSupportedExtByPath(path)) {
            path = a.getIntent().getData().getPath();
        }
        LOG.d("checkOrCreateMetaInfo", path);
        if (new File(path).isFile()) {
            FileMeta fileMeta = AppDB.get().getOrCreate(path);
            if (TxtUtils.isEmpty(fileMeta.getTitle())) {
                EbookMeta ebookMeta = FileMetaCore.get().getEbookMeta(path, CacheDir.ZipApp, false);
                FileMetaCore.get().upadteBasicMeta(fileMeta, new File(path));
                FileMetaCore.get().udpateFullMeta(fileMeta, ebookMeta);
                AppDB.get().update(fileMeta);
                LOG.d("checkOrCreateMetaInfo", "UPDATE", path);
            } else {
                LOG.d("checkOrCreateMetaInfo", "LOAD", path);
            }
        }
    } catch (Exception e) {
        LOG.e(e);
    }
}
Also used : EbookMeta(com.foobnix.ext.EbookMeta) File(java.io.File) FileMeta(com.foobnix.dao2.FileMeta) IOException(java.io.IOException)

Example 10 with FileMeta

use of com.foobnix.dao2.FileMeta in project LibreraReader by foobnix.

the class DefaultListeners method getOnItemClickListener.

public static ResultResponse<FileMeta> getOnItemClickListener(final Activity a) {
    return new ResultResponse<FileMeta>() {

        @Override
        public boolean onResultRecive(FileMeta result) {
            if (isTagCicked(a, result)) {
                return true;
            }
            final File item = new File(result.getPath());
            if (item.isDirectory()) {
                Intent intent = // 
                new Intent(UIFragment.INTENT_TINT_CHANGE).putExtra(MainTabs2.EXTRA_PAGE_NUMBER, // 
                UITab.getCurrentTabIndex(UITab.BrowseFragment));
                LocalBroadcastManager.getInstance(a).sendBroadcast(intent);
                EventBus.getDefault().post(new OpenDirMessage(result.getPath()));
            } else {
                ExtUtils.openFile(a, result);
            }
            return false;
        }
    };
}
Also used : ResultResponse(com.foobnix.android.utils.ResultResponse) OpenDirMessage(com.foobnix.pdf.search.activity.msg.OpenDirMessage) Intent(android.content.Intent) File(java.io.File) DocumentFile(android.support.v4.provider.DocumentFile) FileMeta(com.foobnix.dao2.FileMeta)

Aggregations

FileMeta (com.foobnix.dao2.FileMeta)42 File (java.io.File)26 View (android.view.View)10 OnClickListener (android.view.View.OnClickListener)10 ImageView (android.widget.ImageView)10 TextView (android.widget.TextView)10 Intent (android.content.Intent)8 Bitmap (android.graphics.Bitmap)8 ArrayList (java.util.ArrayList)6 TargetApi (android.annotation.TargetApi)4 AlertDialog (android.app.AlertDialog)4 DialogInterface (android.content.DialogInterface)4 DocumentFile (android.support.v4.provider.DocumentFile)4 RecyclerView (android.support.v7.widget.RecyclerView)4 HorizontalViewActivity (com.foobnix.pdf.search.activity.HorizontalViewActivity)4 MainTabs2 (com.foobnix.ui2.MainTabs2)4 SuppressLint (android.annotation.SuppressLint)3 PendingIntent (android.app.PendingIntent)3 OnDismissListener (android.content.DialogInterface.OnDismissListener)3 Uri (android.net.Uri)3