本文整理汇总了Java中io.plaidapp.data.prefs.DesignerNewsPrefs类的典型用法代码示例。如果您正苦于以下问题:Java DesignerNewsPrefs类的具体用法?Java DesignerNewsPrefs怎么用?Java DesignerNewsPrefs使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DesignerNewsPrefs类属于io.plaidapp.data.prefs包,在下文中一共展示了DesignerNewsPrefs类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: postNewStory
import io.plaidapp.data.prefs.DesignerNewsPrefs; //导入依赖的package包/类
@OnClick(R.id.new_story_post)
protected void postNewStory() {
if (DesignerNewsPrefs.get(this).isLoggedIn()) {
ImeUtils.hideIme(title);
Intent postIntent = new Intent(PostStoryService.ACTION_POST_NEW_STORY, null,
this, PostStoryService.class);
postIntent.putExtra(PostStoryService.EXTRA_STORY_TITLE, title.getText().toString());
postIntent.putExtra(PostStoryService.EXTRA_STORY_URL, url.getText().toString());
postIntent.putExtra(PostStoryService.EXTRA_STORY_COMMENT, comment.getText().toString());
postIntent.putExtra(PostStoryService.EXTRA_BROADCAST_RESULT,
getIntent().getBooleanExtra(PostStoryService.EXTRA_BROADCAST_RESULT, false));
startService(postIntent);
setResult(RESULT_POSTING);
finishAfterTransition();
} else {
Intent login = new Intent(this, DesignerNewsLogin.class);
MorphTransform.addExtras(login, ContextCompat.getColor(this, R.color.designer_news), 0);
ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(
this, post, getString(R.string.transition_designer_news_login));
startActivity(login, options.toBundle());
}
}
示例3: 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
}
}
示例4: 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);
}
示例5: 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);
}
示例6: getDesignerNewsPrefs
import io.plaidapp.data.prefs.DesignerNewsPrefs; //导入依赖的package包/类
public DesignerNewsPrefs getDesignerNewsPrefs() {
return designerNewsPrefs;
}
示例7: 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();
}
}
}
}
示例8: 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();
}
}
}
}