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;
}
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);
}
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;
}
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);
}
}
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;
}
};
}
Aggregations