本文整理汇总了Java中org.ligi.axt.AXT类的典型用法代码示例。如果您正苦于以下问题:Java AXT类的具体用法?Java AXT怎么用?Java AXT使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AXT类属于org.ligi.axt包,在下文中一共展示了AXT类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: showSaveDialog
import org.ligi.axt.AXT; //导入依赖的package包/类
private void showSaveDialog() {
final EditText fileNameET = new EditText(this);
fileNameET.setText(App.getSettings().getRecentFileName());
new AlertDialog.Builder(this)
.setView(fileNameET)
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
final String fileName = fileNameET.getText().toString() + ".aj";
final File outFile = new File(App.getSettings().getScriptDir(), fileName);
AXT.at(outFile).writeString(codeEditText.getText().toString());
App.getSettings().setRecentFileName(fileNameET.getText().toString());
}
})
.setNegativeButton(android.R.string.cancel, null)
.show();
}
示例2: getBitmap
import org.ligi.axt.AXT; //导入依赖的package包/类
private File getBitmap(String tag, Uri url) {
final File cacheDir = context.getCacheDir();
if (!cacheDir.exists()) {
cacheDir.mkdirs();
}
final File f = new File(cacheDir, tag);
try {
final InputStream is = getInputStreamByURL(url);
AXT.at(is).toFile(f);
return f;
} catch (Exception ex) {
ex.printStackTrace();
return null;
}
}
示例3: testThatBasicChatMessagesAreParsed
import org.ligi.axt.AXT; //导入依赖的package包/类
@Test
public void testThatBasicChatMessagesAreParsed() throws IOException, URISyntaxException {
final String json = AXT.at(new File(getClass().getClassLoader().getResource("simple_server_response.json").toURI())).readToString();
final ChatModel chatModel = new ChatModel();
final ServerResponseProcessor tested = new ServerResponseProcessor(mock(OtherUsersLocationModel.class), mock(EventBusProvider.class), chatModel);
tested.process(json);
assertThat(chatModel.getSavedAndOutgoingMessages().size()).isEqualTo(2);
}
示例4: testThatBasicChatMessagesAreSorted
import org.ligi.axt.AXT; //导入依赖的package包/类
@Test
public void testThatBasicChatMessagesAreSorted() throws IOException, URISyntaxException {
final String json = AXT.at(new File(getClass().getClassLoader().getResource("simple_server_response.json").toURI())).readToString();
final ChatModel chatModel = new ChatModel();
final ServerResponseProcessor tested = new ServerResponseProcessor(mock(OtherUsersLocationModel.class), mock(EventBusProvider.class), chatModel);
tested.process(json);
final ReceivedChatMessage message0 = (ReceivedChatMessage) chatModel.getSavedAndOutgoingMessages().get(0);
final ReceivedChatMessage message1 = (ReceivedChatMessage) chatModel.getSavedAndOutgoingMessages().get(1);
assertThat(message0.getTimestamp()).isBefore(message1.getTimestamp());
}
示例5: testThatEventIsFiredForValidJSON
import org.ligi.axt.AXT; //导入依赖的package包/类
@Test
public void testThatEventIsFiredForValidJSON() throws IOException, URISyntaxException {
final String json = AXT.at(new File(getClass().getClassLoader().getResource("simple_server_response.json").toURI())).readToString();
final EventBusProvider eventMock = mock(EventBusProvider.class);
final ServerResponseProcessor tested = new ServerResponseProcessor(mock(OtherUsersLocationModel.class), eventMock, mock(ChatModel.class));
tested.process(json);
verify(eventMock, times(1)).post(Events.NEW_SERVER_RESPONSE_EVENT);
}
示例6: onProgressUpdate
import org.ligi.axt.AXT; //导入依赖的package包/类
@Override
protected void onProgressUpdate(String... values) {
super.onProgressUpdate(values);
try {
final String codeString = AXT.at(new File(values[0])).readToString();
interpreter.eval(codeString);
} catch (IOException e) {
e.printStackTrace();
} catch (EvalError evalError) {
evalError.printStackTrace();
}
}
示例7: copyAssets
import org.ligi.axt.AXT; //导入依赖的package包/类
private void copyAssets(String path) {
final AssetManager assetManager = activity.getAssets();
try {
final String toName = AXT.at(path.split("/")).last();
final File toPath = new File(App.getSettings().getScriptDir() + "/" + toName);
if (!toPath.exists()) {
toPath.mkdirs();
}
final String[] files = assetManager.list(path);
for (String filename : files) {
publishProgress(filename);
final InputStream in = assetManager.open(path + "/" + filename);
final File outFile = new File(toPath, filename);
if (!outFile.exists()) {
if (!outFile.createNewFile()) {
continue;
}
final OutputStream out = new FileOutputStream(outFile);
copyFile(in, out);
in.close();
out.flush();
out.close();
}
}
} catch (IOException e) {
Log.e("tag", "Failed to get asset file list.", e);
}
}
示例8: delete_recursive_should_behave_correct_when_no_dir_there
import org.ligi.axt.AXT; //导入依赖的package包/类
@Test
public void delete_recursive_should_behave_correct_when_no_dir_there() {
File testDir = new File(EXT_DIR, DEFAULT_DIR);
// should not exist
assertThat(testDir.exists()).isEqualTo(false);
// invoke and check return code
assertThat(AXT.at(testDir).deleteRecursive()).isEqualTo(false);
}
示例9: delete_recursive_should_delete_a_single_dir
import org.ligi.axt.AXT; //导入依赖的package包/类
@Test
public void delete_recursive_should_delete_a_single_dir() {
File testDir = new File(EXT_DIR, DEFAULT_DIR);
testDir.mkdir();
// should exist now
assertThat(testDir.exists()).isEqualTo(true);
// invoke and check return code
assertThat(AXT.at(testDir).deleteRecursive()).isEqualTo(true);
assertThat(testDir.exists()).isEqualTo(false);
}
示例10: delete_recursive_should_delete_dirs_recursively
import org.ligi.axt.AXT; //导入依赖的package包/类
@Test
public void delete_recursive_should_delete_dirs_recursively() {
File testDirDeep = new File(EXT_DIR, DEFAULT_DIR + "/" + DEFAULT_DIR + "/" + DEFAULT_DIR);
testDirDeep.mkdirs();
File testDir2Remove = new File(EXT_DIR, DEFAULT_DIR);
// should exist now
assertThat(testDirDeep.exists()).isEqualTo(true);
// invoke and check return code
assertThat(AXT.at(testDir2Remove).deleteRecursive()).isEqualTo(true);
assertThat(testDirDeep.exists()).isEqualTo(false);
}
示例11: read_write_file_cycle_should_keep_data
import org.ligi.axt.AXT; //导入依赖的package包/类
@Test
public void read_write_file_cycle_should_keep_data() {
File testFile = new File(EXT_DIR, DEFAULT_DIR + ".txt");
AXT.at(testFile).writeString("SAMPLE");
try {
assertThat(AXT.at(testFile).readToString()).isEqualTo("SAMPLE");
} catch (IOException e) {
fail("the file should be loadable");
}
}
示例12: obj_read_write_roundtrip
import org.ligi.axt.AXT; //导入依赖的package包/类
@Test
public void obj_read_write_roundtrip() throws IOException, ClassNotFoundException {
File testFile = new File(EXT_DIR, DEFAULT_DIR + ".obj");
TestSerializable in = new TestSerializable();
in.test = "TESTING";
AXT.at(testFile).writeObject(in);
TestSerializable out = AXT.at(testFile).loadToObject();
assertThat(in.test).isEqualTo(out.test);
}
示例13: string_read_write_roundtrip
import org.ligi.axt.AXT; //导入依赖的package包/类
@Test
public void string_read_write_roundtrip() throws IOException, ClassNotFoundException {
File testFile = new File(EXT_DIR, "foo.txt");
String probe = "foo\r\nbar";
AXT.at(testFile).writeString(probe);
final String read = AXT.at(testFile).readToString();
assertThat(probe).isEqualTo(read);
}
示例14: size_as_point_works
import org.ligi.axt.AXT; //导入依赖的package包/类
@Test
public void size_as_point_works() {
Bitmap origBitmap = Bitmap.createBitmap(SIZE_X_PROBE, SIZE_Y_PROBE, Bitmap.Config.ARGB_8888);
Point sizeAsPoint = AXT.at(origBitmap).getSizeAsPoint();
Assertions.assertThat(sizeAsPoint).isEqualTo(new Point(SIZE_X_PROBE, SIZE_Y_PROBE));
}
示例15: should_write_file_correctly
import org.ligi.axt.AXT; //导入依赖的package包/类
@Test
public void should_write_file_correctly() throws IOException {
File file = new File(ROOT, "foo1");
AXT.at(new StringInputStream(STRING_PROBE)).toFile(file);
assertThat(STRING_PROBE).isEqualTo(AXT.at(file).readToString());
}