question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

About use ReadLocatorListener

See original GitHub issue

Issue / Feature - The ReadLocatorListener is not working - Can not save last read position FolioReader version - 0.5.4 FolioReader Stock / Modified - Modified Android SDK - Android SDK API 21-28 Mobile / Tablet / Emulator Info - Genymotion Custom Phone 5.0 Crash / Error - it look like no work.

Steps to reproduce / Describe in detail -

package com.example.administrator.nreader;

import androidx.appcompat.app.AppCompatActivity; import androidx.core.app.ActivityCompat; import androidx.core.content.ContextCompat; import cn.finalteam.filedownloaderfinal.DownloaderManager; import cn.finalteam.filedownloaderfinal.DownloaderManagerConfiguration; import cn.finalteam.filedownloaderfinal.FileDownloaderCallback; import cn.finalteam.filedownloaderfinal.SimpleFileDownloader; import cn.finalteam.toolsfinal.StorageUtils;

import android.Manifest; import android.content.Context; import android.content.pm.PackageManager; import android.os.Build; import android.os.Bundle; import android.os.Environment; import android.util.Log; import android.view.View; import android.widget.Button; import android.widget.ProgressBar; import android.widget.TextView; import android.widget.Toast;

import com.folioreader.Config; import com.folioreader.Constants; import com.folioreader.FolioReader; import com.folioreader.model.locators.ReadLocator; import com.folioreader.util.ReadLocatorListener; import com.liulishuo.filedownloader.BaseDownloadTask; import com.liulishuo.filedownloader.FileDownloadConnectListener; import com.liulishuo.filedownloader.FileDownloadListener; import com.liulishuo.filedownloader.FileDownloadSampleListener; import com.liulishuo.filedownloader.FileDownloader;

import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.lang.ref.WeakReference; import java.net.MalformedURLException; import java.net.URL; import java.net.URLConnection; import java.util.regex.Matcher; import java.util.regex.Pattern;

public class MainActivity extends AppCompatActivity implements ReadLocatorListener {

private FolioReader folioReader;
private String status = null;
private String path;
private String save_path;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    if (Build.VERSION.SDK_INT >= 23) {
        if (ContextCompat.checkSelfPermission(MainActivity.this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
            ActivityCompat.requestPermissions(MainActivity.this, new String[]{android.Manifest.permission.WRITE_EXTERNAL_STORAGE}, 1);
        }
    }

    //application

// Environment.getExternalStorageDirectory().getPath() save_path = “/mnt/sdcard/Signature/”;

    path = "http://114.116.48.166/lianmao/public/uploads/picture/uid2/member/20190227/38a9420c267c6c2983de788341edc82a.epub";
    String[] paths = path.split("/");
    int l = paths.length - 1;
    String str_ = paths[l];
    Log.i("info:::", str_);

    File file = new File(save_path + str_);
    if (!file.exists()) {
        download();
    } else {
        getFolioReader(save_path + str_);
    }

}

private void getFolioReader(String path) {

    folioReader = FolioReader
            .get()
    .setReadLocatorListener(this);

    Config config = new Config()
            .setAllowedDirection(Config.AllowedDirection.ONLY_HORIZONTAL)
            .setDirection(Config.Direction.HORIZONTAL);

    folioReader.setConfig(config, true);
    folioReader.openBook(path);
}

//下载到本地
private void download() {
    DownloadUtil.getInstance().download(path, save_path, new DownloadUtil.OnDownloadListener() {
        @Override
        public void onDownloadSuccess(String path) {
            Log.i("info:::", "成功:" + path);
            getFolioReader(path);
        }

        @Override
        public void onDownloading(int progress) {
            Log.i("info:::", "进度:" + progress);
        }

        @Override
        public void onDownloadFailed() {
            Log.i("info:::", "失败");
        }
    });
}

@Override
public void saveReadLocator(ReadLocator readLocator) {
    Log.i("info:::","---here---");
}

#}

this funcation is not working,because the logs are not printed @Override public void saveReadLocator(ReadLocator readLocator) { Log.i(“info:::”,“—here—”); }

plz,help~~

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6

github_iconTop GitHub Comments

6reactions
GzxdHcommented, Mar 1, 2019

What should I do to save the page position?

0reactions
y-zianecommented, Jan 3, 2021

same problem too 😦

Read more comments on GitHub >

github_iconTop Results From Across the Web

Multiple consumers using spring kafka - Stack Overflow
I am looking to setup multiple listeners on a kafka topic inside my application. Below is my setup. it is supposed to be...
Read more >
com.folioreader.FolioReader.setReadLocator java code examples ...
<init> · clear. Nullifies readLocator and listeners. This method ideally should be used in onDestroy() of Activity o · get · getIntentFromUrl ·...
Read more >
FolioReader-Android/FolioReader.java at master - GitHub
* Nullifies readLocator and listeners. * This method ideally should be used in onDestroy() of Activity or Fragment. * Use this method if...
Read more >
Release Notes for Oracle Coherence
Read Locator - Coherence now allows for certain requests for data to be targeted to non-primary partition owners (backups) to balance request load...
Read more >
AndroidFacade — QPython 0.9 documentation
If used, requires packagename to be useful. Returns. A Map representation of the result Intent. sample code to show startActivityForResult.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found