本文整理了Java中com.zulip.android.ZulipApp
类的一些代码示例,展示了ZulipApp
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZulipApp
类的具体详情如下:
包路径:com.zulip.android.ZulipApp
类名称:ZulipApp
[英]Stores the global variables which are frequently used.
#max_message_id This is the last Message ID stored in our database. #you A reference to the user currently logged in. #api_key Stores the API_KEY which was obtained from the server on successful authentication. #setupEmoji() This is called to initialize and add records the existing emoticons in the assets folder.
[中]存储经常使用的全局变量。
#max_message_id这是我们数据库中存储的最后一个消息id#您可以创建当前登录用户的引用#api_密钥存储成功身份验证时从服务器获得的api_密钥#setupEmoji()调用它来初始化和添加资产文件夹中现有的表情符号。
代码示例来源:origin: zulip/zulip-android
public ExpandableStreamDrawerAdapter(final Context context, Cursor cursor, int groupLayout,
String[] groupFrom, int[] groupTo, int childLayout,
String[] childFrom, int[] childTo) {
super(context, cursor, groupLayout, groupFrom, groupTo, childLayout, childFrom, childTo);
zulipApp = ZulipApp.get();
}
代码示例来源:origin: zulip/zulip-android
@Override
public Response intercept(Chain chain) throws IOException {
Request.Builder requestBuilder = chain.request().newBuilder();
requestBuilder.addHeader("client", "Android");
requestBuilder.addHeader("User-Agent", app.getUserAgent());
if (app.getApiKey() != null) {
String authstr = app.getEmail() + ":" + app.getApiKey();
requestBuilder.addHeader("Authorization", "Basic " + Base64.encodeToString(authstr.getBytes(), Base64.NO_WRAP));
}
Request request = requestBuilder.build();
return chain.proceed(request);
}
}
代码示例来源:origin: zulip/zulip-android
public <C, T> RuntimeExceptionDao<C, T> getDao(Class<C> cls) {
return getDao(cls, false);
}
代码示例来源:origin: zulip/zulip-android
public void onResetDatabase() {
setPointer(-1);
setMaxMessageId(-1);
setLastEventId(-1);
setEventQueueId(null);
}
代码示例来源:origin: zulip/zulip-android
@Override
public void onClick(DialogInterface dialogInterface, int i) {
ZulipApp.get().setDontShowAppDialog(true);
}
});
代码示例来源:origin: zulip/zulip-android
@Override
public String getTitle() {
return ZulipApp.get().getString(R.string.mentions);
}
代码示例来源:origin: zulip/zulip-android
/**
* Registers for a new event queue with the Zulip API
*/
private void register() throws JSONException, IOException {
retrofit2.Response<UserConfigurationResponse> response = app.getZulipServices()
.register(true)
.execute();
if (response.isSuccessful()) {
UserConfigurationResponse res = response.body();
app.tester = app.getEventQueueId();
app.setEventQueueId(res.getQueueId());
app.setLastEventId(res.getLastEventId());
app.setPointer(res.getPointer());
app.setMaxMessageId(res.getMaxMessageId());
app.setMessageContentEditParams(res.getRealmMessageContentEditLimitSeconds(),
res.isRealmAllowMessageEditing());
registeredOrGotEventsThisRun = true;
processRegister(res);
}
}
代码示例来源:origin: zulip/zulip-android
@Before
public void setUp() {
if (ZulipApp.get().getApiKey() != null) {
logout();
}
}
代码示例来源:origin: zulip/zulip-android
@Before
public void setUp() {
app = ZulipApp.get();
if (ZulipApp.get().getApiKey() == null) {
BaseTest baseTest = new BaseTest();
baseTest.login();
sleep(4000);
}
//This is to make sure the latest recieved messages will be added to the list!
app.setPointer(app.getMaxMessageId());
setTestMessageStream((testMessageStream == null) ? RandomStringUtils.randomAlphanumeric(10) : testMessageStream);
setTestMessagePrivate((testMessagePrivate == null) ? RandomStringUtils.randomAlphanumeric(15) : testMessagePrivate);
}
代码示例来源:origin: zulip/zulip-android
/**
* Run this before each test to set up the activity.
*/
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
private void prepTests() {
setApplication(app);
this.startActivity(new Intent(getInstrumentation().getTargetContext(),
ZulipActivity.class), null, null);
this.getInstrumentation().waitForIdleSync();
app.setContext(getInstrumentation().getTargetContext());
// Need to setEmail twice to reinitialise the database after destroying
// it.
app.setEmail(TESTUSER_EXAMPLE_COM);
app.deleteDatabase(app.getDatabaseHelper().getDatabaseName());
app.setEmail(TESTUSER_EXAMPLE_COM);
messageDao = app.getDao(Message.class);
}
代码示例来源:origin: zulip/zulip-android
@Override
public void onDataSetChanged() {
Log.i("ZULIP_WIDGET", "onDataSetChanged() = Data reloaded");
QueryBuilder<Message, Object> queryBuilder = ZulipApp.get().getDao(Message.class).queryBuilder();
String filter;
filter = setupWhere();
if (!filter.equals("")) {
queryBuilder.where().raw(filter);
}
try {
messageList = queryBuilder.query();
} catch (SQLException e) {
ZLog.logException(e);
}
}
代码示例来源:origin: zulip/zulip-android
public Response execute() throws IOException {
if (method == null)
throw new IOException(app.getString(R.string.method_null));
Request.Builder requestBuilder = new Request.Builder();
String url = app.getServerURI() + path;
requestBuilder.addHeader("client", "Android");
requestBuilder.addHeader("User-Agent", app.getUserAgent());
break;
default:
throw new IOException(app.getString(R.string.method_error));
if (this.app.getApiKey() != null) {
String authstr = this.app.getEmail() + ":" + this.app.getApiKey();
requestBuilder.addHeader("Authorization", "Basic " + Base64.encodeToString(authstr.getBytes(), Base64.NO_WRAP));
代码示例来源:origin: zulip/zulip-android
public static void updateNewMessagesRange(ZulipApp app, int maxId) {
synchronized (app.updateRangeLock) {
RuntimeExceptionDao<MessageRange, Integer> rangeDao = app
.getDao(MessageRange.class);
MessageRange currentRange = MessageRange.getRangeContaining(
app.getMaxMessageId(), rangeDao);
if (currentRange == null) {
currentRange = new MessageRange(app.getMaxMessageId(),
app.getMaxMessageId());
}
if (currentRange.high <= maxId) {
currentRange.high = maxId;
rangeDao.createOrUpdate(currentRange);
}
}
app.setMaxMessageId(maxId);
}
代码示例来源:origin: zulip/zulip-android
public static void markRange(ZulipApp app, final int low, final int high) {
final RuntimeExceptionDao<MessageRange, Integer> messageRangeDao = app
.getDao(MessageRange.class);
try {
synchronized (app.updateRangeLock) {
TransactionManager.callInTransaction(app.getDatabaseHelper()
.getConnectionSource(), new Callable<Void>() {
public Void call() throws Exception {
代码示例来源:origin: zulip/zulip-android
@Override
public String getComposePMRecipient() {
return Message.emailsMinusYou(people, ZulipApp.get().getYou());
}
代码示例来源:origin: zulip/zulip-android
/**
* Performs the click action associated with this span.
*/
@Override
public void onClick(View widget) {
Context context = widget.getContext().getApplicationContext();
// get stream name from streamId string
String streamName = null;
if (StringUtils.isNumeric(streamId)) {
Stream stream = Stream.getById(ZulipApp.get(), Integer.parseInt(streamId));
if (stream != null) {
streamName = stream.getName();
}
// go to last message read in the stream
if (streamName != null) {
(((ZulipApp) context).getZulipActivity()).doNarrowToLastRead(streamName);
}
}
}
代码示例来源:origin: zulip/zulip-android
/**
* Refresh the current user profile, removes all the tables from the database and reloads them from the server, reset the queue.
*/
private void onRefresh() {
super.onResume();
if (event_poll != null) {
event_poll.abort();
event_poll = null;
}
app.clearConnectionState();
app.resetDatabase();
app.setEmail(app.getYou().getEmail());
startRequests();
}
代码示例来源:origin: zulip/zulip-android
/**
* Fills the Emoji Table with the existing emoticons saved in the assets folder.
*/
private void setupEmoji() {
try {
final RuntimeExceptionDao<Emoji, Object> dao = getDao(Emoji.class);
if (dao.queryForAll().size() != 0) return;
final String emojis[] = getAssets().list("emoji");
TransactionManager.callInTransaction(getDatabaseHelper()
.getConnectionSource(),
new Callable<Void>() {
public Void call() throws Exception {
for (String newEmoji : emojis) {
//currently emojis are in png format
newEmoji = newEmoji.replace(".png", "");
dao.create(new Emoji(newEmoji));
}
return null;
}
});
} catch (SQLException | IOException e) {
ZLog.logException(e);
}
}
代码示例来源:origin: zulip/zulip-android
private static void endSpan(SpannableStringBuilder text) {
int len = text.length();
Object obj = getLast(text, Href.class);
int where = text.getSpanStart(obj);
text.removeSpan(obj);
if (where != len) {
if (isEmoji) {
text.delete(where, len);
return;
}
Href h = (Href) obj;
if (h != null && h.mHref != null) {
if (ZulipApp.get().getEmail().equals(h.mHref)) {
text.setSpan(new ForegroundColorSpan(userMentionSelfColor), where, len, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
} else {
text.setSpan(new ProfileSpan(h.mHref, userMentionColor), where, len, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
}
}
}
}
代码示例来源:origin: zulip/zulip-android
@Override
public void onClick(View widget) {
Context context = widget.getContext().getApplicationContext();
List<Person> people = new ArrayList<Person>();
if (email.equals("*")) { //This is for "@all"
try {
people = Person.getAllPeople(ZulipApp.get());
} catch (SQLException e) {
ZLog.logException(e);
return;
}
} else {
for (String email : this.email.split(",")) {
Person person = Person.getByEmail(ZulipApp.get(), email);
if (person != null) {
people.add(person);
}
}
people.add(ZulipApp.get().getYou());
}
(((ZulipApp) context).getZulipActivity()).doNarrow(new NarrowFilterPM(people));
}
内容来源于网络,如有侵权,请联系作者删除!