本文整理汇总了Java中com.uservoice.uservoicesdk.Session类的典型用法代码示例。如果您正苦于以下问题:Java Session类的具体用法?Java Session怎么用?Java Session使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Session类属于com.uservoice.uservoicesdk包,在下文中一共展示了Session类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: signIn
import com.uservoice.uservoicesdk.Session; //导入依赖的package包/类
private void signIn() {
User currentUser = Session.getInstance().getUser();
if (currentUser != null && (email == null || email.equals(currentUser.getEmail()))) {
callback.run();
} else {
email = email == null ? Session.getInstance().getEmail() : email;
name = name == null ? Session.getInstance().getName() : name;
if (email != null) {
User.discover(email, new Callback<User>() {
@Override
public void onModel(User model) {
promptToSignIn();
}
@Override
public void onError(RestResult error) {
createUser();
}
});
} else {
promptToSignIn();
}
}
}
示例2: createRequest
import com.uservoice.uservoicesdk.Session; //导入依赖的package包/类
private HttpUriRequest createRequest() throws URISyntaxException, UnsupportedEncodingException {
String host = Session.getInstance().getConfig().getSite();
Uri.Builder uriBuilder = new Uri.Builder();
uriBuilder.scheme(host.contains(".us.com") ? "http" : "https");
uriBuilder.encodedAuthority(host);
uriBuilder.path(urlPath);
if (method == RestMethod.GET)
return requestWithQueryString(new HttpGet(), uriBuilder);
else if (method == RestMethod.DELETE)
return requestWithQueryString(new HttpDelete(), uriBuilder);
else if (method == RestMethod.POST)
return requestWithEntity(new HttpPost(), uriBuilder);
else if (method == RestMethod.PUT)
return requestWithEntity(new HttpPut(), uriBuilder);
else
throw new IllegalArgumentException("Method must be one of [GET, POST, PUT, DELETE], but was " + method);
}
示例3: doSubmit
import com.uservoice.uservoicesdk.Session; //导入依赖的package包/类
@Override
protected void doSubmit() {
SigninManager.signIn(context, emailField.getText().toString(), nameField.getText().toString(), new Runnable() {
@Override
public void run() {
Category category = categorySelect == null ? null : (Category) categorySelect.getSelectedItem();
Suggestion.createSuggestion(Session.getInstance().getForum(), category, textField.getText().toString(), descriptionField.getText().toString(), 1, new DefaultCallback<Suggestion>(context) {
@Override
public void onModel(Suggestion model) {
Babayaga.track(Event.SUBMIT_IDEA);
Toast.makeText(context, R.string.uv_msg_idea_created, Toast.LENGTH_SHORT).show();
context.finish();
}
});
}
});
}
示例4: getCount
import com.uservoice.uservoicesdk.Session; //导入依赖的package包/类
@Override
public int getCount() {
if (!configLoaded) {
return 1;
} else {
computeStaticRows();
int rows = staticRows.size();
if (Session.getInstance().getConfig().shouldShowKnowledgeBase()) {
if (getTopics() == null || (shouldShowArticles() && getArticles() == null)) {
rows += 1;
} else {
rows += shouldShowArticles() ? getArticles().size() : getTopics().size();
}
}
return rows;
}
}
示例5: loadForum
import com.uservoice.uservoicesdk.Session; //导入依赖的package包/类
private void loadForum() {
if (Session.getInstance().getForum() != null) {
forum = Session.getInstance().getForum();
Babayaga.track(Babayaga.Event.VIEW_FORUM, forum.getId());
setTitle(forum.getName());
getModelAdapter().loadMore();
return;
}
Forum.loadForum(Session.getInstance().getConfig().getForumId(), new DefaultCallback<Forum>(this) {
@Override
public void onModel(Forum model) {
Session.getInstance().setForum(model);
forum = model;
setTitle(forum.getName());
getModelAdapter().loadMore();
}
});
}
示例6: init
import com.uservoice.uservoicesdk.Session; //导入依赖的package包/类
public void init() {
if (Session.getInstance().getClientConfig() == null) {
ClientConfig.loadClientConfig(context, new DefaultCallback<ClientConfig>(context) {
@Override
public void onModel(ClientConfig model) {
Session.getInstance().setClientConfig(model);
// if we are getting the client config, they are launching the ui
// do this here so that we have the subdomain id, so that the channel event works for now
// once babayaga actually supports recording events using the subdomain key, this could be moved back to UserVoice.java
Babayaga.track(context, Babayaga.Event.VIEW_CHANNEL);
loadUser();
}
});
} else {
loadUser();
}
}
示例7: createRequest
import com.uservoice.uservoicesdk.Session; //导入依赖的package包/类
private Request createRequest() throws URISyntaxException, UnsupportedEncodingException {
Request.Builder builder = new Request.Builder()
.addHeader("Accept-Language", Locale.getDefault().getLanguage())
.addHeader("API-Client", String.format("uservoice-android-%s", UserVoice.getVersion()))
.addHeader("User-Agent", String.format("uservoice-android-%s", UserVoice.getVersion()));
String host = Session.getInstance().getConfig(context).getSite();
Uri.Builder uriBuilder = new Uri.Builder();
uriBuilder.scheme(host.contains(".us.com") ? "http" : "https");
uriBuilder.encodedAuthority(host);
uriBuilder.path(urlPath);
if (method == RestMethod.GET || method == RestMethod.DELETE) {
builder.method(method.toString(), null);
addParamsToQueryString(builder, uriBuilder);
} else {
builder.url(uriBuilder.build().toString());
addParamsToBody(builder);
}
return builder.build();
}
示例8: getCount
import com.uservoice.uservoicesdk.Session; //导入依赖的package包/类
@Override
public int getCount() {
if (!configLoaded) {
return 1;
} else {
computeStaticRows();
int rows = staticRows.size();
if (Session.getInstance().getConfig(context).shouldShowKnowledgeBase()) {
if (getTopics() == null || (shouldShowArticles() && articles == null)) {
rows += 1;
} else {
rows += shouldShowArticles() ? articles.size() : getTopics().size();
}
}
if (!Session.getInstance().getClientConfig().isWhiteLabel()) {
rows += 1;
}
return rows;
}
}
示例9: getItemViewType
import com.uservoice.uservoicesdk.Session; //导入依赖的package包/类
@Override
public int getItemViewType(int position) {
if (!configLoaded)
return LOADING;
computeStaticRows();
if (position < staticRows.size()) {
int type = staticRows.get(position);
if (type == FORUM && Session.getInstance().getForum() == null)
return LOADING;
return type;
}
if (Session.getInstance().getConfig(context).shouldShowKnowledgeBase()) {
if (getTopics() == null || (shouldShowArticles() && articles == null)) {
if (position - staticRows.size() == 0)
return LOADING;
} else if (shouldShowArticles() && position - staticRows.size() < articles.size()) {
return ARTICLE;
} else if (!shouldShowArticles() && position - staticRows.size() < getTopics().size()) {
return TOPIC;
}
}
return POWERED_BY;
}
示例10: loadForum
import com.uservoice.uservoicesdk.Session; //导入依赖的package包/类
private void loadForum() {
if (Session.getInstance().getForum() != null) {
forum = Session.getInstance().getForum();
Babayaga.track(this, Babayaga.Event.VIEW_FORUM, forum.getId());
setTitle(forum.getName());
getModelAdapter().loadMore();
return;
}
Forum.loadForum(this, Session.getInstance().getConfig(this).getForumId(), new DefaultCallback<Forum>(this) {
@Override
public void onModel(Forum model) {
Session.getInstance().setForum(model);
forum = model;
setTitle(forum.getName());
getModelAdapter().loadMore();
}
});
}
示例11: logout
import com.uservoice.uservoicesdk.Session; //导入依赖的package包/类
public static void logout(Context context) {
PreferenceUtils.clearLoginInformation(context);
Utils.clearUserVoiceUser(context, Session.getInstance());
Utils.clearRavenUser();
Intent loginActivity = new Intent(context, LoginActivity.class);
loginActivity.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(loginActivity);
}
示例12: clearUserVoiceUser
import com.uservoice.uservoicesdk.Session; //导入依赖的package包/类
@SuppressLint("ApplySharedPref")
private static void clearUserVoiceUser(Context context, Session session) {
if (session != null) {
session.setUser(context, new User());
SharedPreferences.Editor edit = session.getSharedPreferences(context).edit();
edit.remove("user_name");
edit.remove("user_email");
edit.commit();
}
}
示例13: init
import com.uservoice.uservoicesdk.Session; //导入依赖的package包/类
public void init() {
if (Session.getInstance().getClientConfig() == null) {
ClientConfig.loadClientConfig(new DefaultCallback<ClientConfig>(context) {
@Override
public void onModel(ClientConfig model) {
Session.getInstance().setClientConfig(model);
loadUser();
}
});
} else {
loadUser();
}
}
示例14: track
import com.uservoice.uservoicesdk.Session; //导入依赖的package包/类
public static void track(String event, Map<String, Object> eventProps) {
if (Session.getInstance().getClientConfig() == null) {
queue.add(new Track(event, eventProps));
} else {
// Log.d("UV", "BY flushing: " + event);
new BabayagaTask(event, uvts, traits, eventProps).execute();
}
}
示例15: findOrCreate
import com.uservoice.uservoicesdk.Session; //导入依赖的package包/类
public static void findOrCreate(String email, String name, String guid, final Callback<AccessTokenResult<User>> callback) {
Map<String, String> params = new HashMap<String, String>();
params.put("user[display_name]", name);
params.put("user[email]", email);
params.put("user[guid]", guid);
params.put("request_token", Session.getInstance().getRequestToken().getKey());
doPost(apiPath("/users/find_or_create.json"), params, new RestTaskCallback(callback) {
@Override
public void onComplete(JSONObject result) throws JSONException {
AccessToken accessToken = deserializeObject(result, "token", AccessToken.class);
User user = deserializeObject(result, "user", User.class);
callback.onModel(new AccessTokenResult<User>(user, accessToken));
}
});
}