本文整理汇总了Java中io.plaidapp.data.prefs.DesignerNewsPrefs.get方法的典型用法代码示例。如果您正苦于以下问题:Java DesignerNewsPrefs.get方法的具体用法?Java DesignerNewsPrefs.get怎么用?Java DesignerNewsPrefs.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.plaidapp.data.prefs.DesignerNewsPrefs
的用法示例。
在下文中一共展示了DesignerNewsPrefs.get方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleActionUpvote
import io.plaidapp.data.prefs.DesignerNewsPrefs; //导入方法依赖的package包/类
private void handleActionUpvote(long storyId) {
if (storyId == 0l) return;
final DesignerNewsPrefs designerNewsPrefs = DesignerNewsPrefs.get(this);
if (!designerNewsPrefs.isLoggedIn()) {
// TODO prompt for login
return;
}
final Call<StoryResponse> upvoteStoryCall = designerNewsPrefs.getApi().upvoteStory(storyId);
try {
final Response<StoryResponse> response = upvoteStoryCall.execute();
final int newVotesCount = response.body().story.vote_count;
// TODO report success
} catch (Exception e) {
// TODO report failure
}
}
示例2: handleActionUpvote
import io.plaidapp.data.prefs.DesignerNewsPrefs; //导入方法依赖的package包/类
private void handleActionUpvote(long storyId) {
if (storyId == 0L) return;
final DesignerNewsPrefs designerNewsPrefs = DesignerNewsPrefs.get(this);
if (!designerNewsPrefs.isLoggedIn()) {
// TODO prompt for login
return;
}
final Call<Story> upvoteStoryCall = designerNewsPrefs.getApi().upvoteStory(storyId);
try {
final Response<Story> response = upvoteStoryCall.execute();
// int newVotesCount = response.body().vote_count;
// TODO report success
} catch (Exception e) {
// TODO report failure
}
}
示例3: onCreate
import io.plaidapp.data.prefs.DesignerNewsPrefs; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_designer_news_login);
ButterKnife.bind(this);
if (!FabTransform.setup(this, container)) {
MorphTransform.setup(this, container,
ContextCompat.getColor(this, R.color.background_light),
getResources().getDimensionPixelSize(R.dimen.dialog_corners));
}
loading.setVisibility(View.GONE);
setupAccountAutocomplete();
username.addTextChangedListener(loginFieldWatcher);
// the primer checkbox messes with focus order so force it
username.setOnEditorActionListener((v, actionId, event) -> {
if (actionId == EditorInfo.IME_ACTION_NEXT) {
password.requestFocus();
return true;
}
return false;
});
password.addTextChangedListener(loginFieldWatcher);
password.setOnEditorActionListener((v, actionId, event) -> {
if (actionId == EditorInfo.IME_ACTION_DONE && isLoginValid()) {
login.performClick();
return true;
}
return false;
});
designerNewsPrefs = DesignerNewsPrefs.get(this);
}
示例4: BaseDataManager
import io.plaidapp.data.prefs.DesignerNewsPrefs; //导入方法依赖的package包/类
public BaseDataManager(@NonNull Context context) {
loadingCount = new AtomicInteger(0);
designerNewsPrefs = DesignerNewsPrefs.get(context);
dribbblePrefs = DribbblePrefs.get(context);
}
示例5: onHandleIntent
import io.plaidapp.data.prefs.DesignerNewsPrefs; //导入方法依赖的package包/类
@Override
protected void onHandleIntent(Intent intent) {
if (intent == null) return;
if (ACTION_POST_NEW_STORY.equals(intent.getAction())) {
final boolean broadcastResult = intent.getBooleanExtra(EXTRA_BROADCAST_RESULT, false);
final DesignerNewsPrefs designerNewsPrefs = DesignerNewsPrefs.get(this);
if (!designerNewsPrefs.isLoggedIn()) return; // shouldn't happen...
final String title = intent.getStringExtra(EXTRA_STORY_TITLE);
final String url = intent.getStringExtra(EXTRA_STORY_URL);
final String comment = intent.getStringExtra(EXTRA_STORY_COMMENT);
if (TextUtils.isEmpty(title)) return;
NewStoryRequest storyToPost = null;
if (!TextUtils.isEmpty(url)) {
storyToPost = NewStoryRequest.createWithUrl(title, url);
} else if (!TextUtils.isEmpty(comment)) {
storyToPost = NewStoryRequest.createWithComment(title, comment);
}
if (storyToPost == null) return;
final Call<StoriesResponse> postStoryCall =
designerNewsPrefs.getApi().postStory(storyToPost);
try {
final Response<StoriesResponse> response = postStoryCall.execute();
final StoriesResponse story = response.body();
if (story != null && story.stories != null && !story.stories.isEmpty()) {
if (broadcastResult) {
final Intent success = new Intent(BROADCAST_ACTION_SUCCESS);
// API doesn't fill in author details so add them here
final Story returnedStory = story.stories.get(0);
final Story.Builder builder = Story.Builder.from(returnedStory)
.setUserId(designerNewsPrefs.getUserId())
.setUserDisplayName(designerNewsPrefs.getUserName())
.setUserPortraitUrl(designerNewsPrefs.getUserAvatar());
// API doesn't add a self URL, so potentially add one for consistency
if (TextUtils.isEmpty(returnedStory.url)) {
builder.setDefaultUrl(returnedStory.id);
}
final Story newStory = builder.build();
newStory.dataSource = SOURCE_NEW_DN_POST;
success.putExtra(EXTRA_NEW_STORY, newStory);
LocalBroadcastManager.getInstance(getApplicationContext())
.sendBroadcast(success);
} else {
Toast.makeText(getApplicationContext(), "Story posted",
Toast.LENGTH_SHORT).show();
}
}
} catch (Exception e) {
final String reason = e.getMessage();
if (broadcastResult) {
final Intent failure = new Intent(BROADCAST_ACTION_FAILURE);
failure.putExtra(BROADCAST_ACTION_FAILURE_REASON, reason);
LocalBroadcastManager.getInstance(getApplicationContext())
.sendBroadcast(failure);
} else {
Toast.makeText(getApplicationContext(), reason, Toast.LENGTH_SHORT).show();
}
}
}
}
示例6: onHandleIntent
import io.plaidapp.data.prefs.DesignerNewsPrefs; //导入方法依赖的package包/类
@Override
protected void onHandleIntent(Intent intent) {
if (intent == null) return;
if (ACTION_POST_NEW_STORY.equals(intent.getAction())) {
final boolean broadcastResult = intent.getBooleanExtra(EXTRA_BROADCAST_RESULT, false);
final DesignerNewsPrefs designerNewsPrefs = DesignerNewsPrefs.get(this);
if (!designerNewsPrefs.isLoggedIn()) return; // shouldn't happen...
final String title = intent.getStringExtra(EXTRA_STORY_TITLE);
final String url = intent.getStringExtra(EXTRA_STORY_URL);
final String comment = intent.getStringExtra(EXTRA_STORY_COMMENT);
if (TextUtils.isEmpty(title)) return;
NewStoryRequest storyToPost = null;
if (!TextUtils.isEmpty(url)) {
storyToPost = NewStoryRequest.createWithUrl(title, url);
} else if (!TextUtils.isEmpty(comment)) {
storyToPost = NewStoryRequest.createWithComment(title, comment);
}
if (storyToPost == null) return;
final Call<List<Story>> postStoryCall =
designerNewsPrefs.getApi().postStory(storyToPost);
try {
final Response<List<Story>> response = postStoryCall.execute();
final List<Story> stories = response.body();
if (stories != null && !stories.isEmpty()) {
if (broadcastResult) {
final Intent success = new Intent(BROADCAST_ACTION_SUCCESS);
// API doesn't fill in author details so add them here
final Story returnedStory = stories.get(0);
final Story.Builder builder = Story.Builder.from(returnedStory)
.setUserId(designerNewsPrefs.getUserId())
.setUserDisplayName(designerNewsPrefs.getUserName())
.setUserPortraitUrl(designerNewsPrefs.getUserAvatar());
// API doesn't add a self URL, so potentially add one for consistency
if (TextUtils.isEmpty(returnedStory.url)) {
builder.setDefaultUrl(returnedStory.id);
}
final Story newStory = builder.build();
newStory.dataSource = SOURCE_NEW_DN_POST;
success.putExtra(EXTRA_NEW_STORY, newStory);
LocalBroadcastManager.getInstance(getApplicationContext())
.sendBroadcast(success);
} else {
Toast.makeText(getApplicationContext(), "Story posted",
Toast.LENGTH_SHORT).show();
}
}
} catch (Exception e) {
final String reason = e.getMessage();
if (broadcastResult) {
final Intent failure = new Intent(BROADCAST_ACTION_FAILURE);
failure.putExtra(BROADCAST_ACTION_FAILURE_REASON, reason);
LocalBroadcastManager.getInstance(getApplicationContext())
.sendBroadcast(failure);
} else {
Toast.makeText(getApplicationContext(), reason, Toast.LENGTH_SHORT).show();
}
}
}
}