mirror of
https://github.com/leanote/leanote-android.git
synced 2025-10-16 07:19:28 +00:00
code refactor: open url
This commit is contained in:
@@ -36,6 +36,7 @@ import org.houxg.leamonax.editor.MarkdownEditor;
|
||||
import org.houxg.leamonax.editor.RichTextEditor;
|
||||
import org.houxg.leamonax.utils.CollectionUtils;
|
||||
import org.houxg.leamonax.utils.DialogUtils;
|
||||
import org.houxg.leamonax.utils.OpenUtils;
|
||||
import org.houxg.leamonax.widget.ToggleImageButton;
|
||||
|
||||
import java.util.List;
|
||||
@@ -392,7 +393,7 @@ public class EditorFragment extends Fragment implements Editor.EditorListener {
|
||||
}
|
||||
});
|
||||
} else {
|
||||
//TODO: go to link
|
||||
OpenUtils.openUrl(getActivity(), url);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -456,8 +457,7 @@ public class EditorFragment extends Fragment implements Editor.EditorListener {
|
||||
|
||||
@Override
|
||||
public void linkTo(String url) {
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
|
||||
startActivity(intent);
|
||||
OpenUtils.openUrl(getActivity(), url);
|
||||
}
|
||||
|
||||
private void refreshFormatStatus(Map<Editor.Format, Object> formatStatus) {
|
||||
|
@@ -5,6 +5,8 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
|
||||
import org.houxg.leamonax.R;
|
||||
|
||||
public class OpenUtils {
|
||||
|
||||
public static void openUrl(Context context, String url) {
|
||||
@@ -13,7 +15,7 @@ public class OpenUtils {
|
||||
try {
|
||||
context.startActivity(i);
|
||||
} catch (Exception ex) {
|
||||
ToastUtils.show(context, "Can't open this url");
|
||||
ToastUtils.show(context, R.string.cant_open_url);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -97,4 +97,5 @@
|
||||
<string name="retry">重试</string>
|
||||
<string name="continue_text">继续</string>
|
||||
<string name="next_time">下次再说</string>
|
||||
<string name="cant_open_url">无法打开该链接</string>
|
||||
</resources>
|
@@ -96,5 +96,6 @@
|
||||
<string name="update_time">Update time</string>
|
||||
<string name="upgrade_now">Upgrade now</string>
|
||||
<string name="your_are_the_latest_version">You are using latest version</string>
|
||||
<string name="cant_open_url">Can\'t open this url</string>
|
||||
|
||||
</resources>
|
||||
|
Reference in New Issue
Block a user