本文整理汇总了Java中com.twitter.sdk.android.tweetcomposer.TweetComposer类的典型用法代码示例。如果您正苦于以下问题:Java TweetComposer类的具体用法?Java TweetComposer怎么用?Java TweetComposer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TweetComposer类属于com.twitter.sdk.android.tweetcomposer包,在下文中一共展示了TweetComposer类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: composeTweet
import com.twitter.sdk.android.tweetcomposer.TweetComposer; //导入依赖的package包/类
@ReactMethod
public void composeTweet(ReadableMap options, final Callback callback) {
try {
this.callback = callback;
String body = options.hasKey("body") ? options.getString("body") : "";
TweetComposer.Builder builder = new TweetComposer.Builder(reactContext).text(body);
final Intent intent = builder.createIntent();
reactContext.startActivityForResult(intent, REQUEST_CODE, intent.getExtras());
} catch (Exception e) {
//error!
sendCallback(false, false, true);
throw e;
}
}
示例2: onOptionsItemSelected
import com.twitter.sdk.android.tweetcomposer.TweetComposer; //导入依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem menuItem) {
if (menuItem.getItemId() == android.R.id.home) {
NavUtils.navigateUpFromSameTask(this);
return true;
} else if (menuItem.getItemId() == R.id.action_share) {
TweetComposer.Builder builder = new TweetComposer.Builder(this)
.text(String.format(getString(R.string.tweet_pattern), mItem.getPrice(), mItem.getName(), mItem.getGuid()));
builder.show();
return true;
} else if(menuItem.getItemId() == R.id.action_bookmark) {
attemptPostBookmark();
return true;
}else {
return super.onOptionsItemSelected(menuItem);
}
}
示例3: onCreate
import com.twitter.sdk.android.tweetcomposer.TweetComposer; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.tweetcomposer_activity_main);
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setTitle(R.string.kit_tweetcomposer);
}
final Button tweetComposer = findViewById(R.id.tweet_composer);
tweetComposer.setOnClickListener(view -> {
try {
new TweetComposer.Builder(TweetComposerMainActivity.this)
.text("Tweet from TwitterKit!")
.url(new URL("http://www.twitter.com"))
.show();
} catch (MalformedURLException e) {
Log.e(TAG, "error creating tweet intent", e);
}
});
final Button organicComposer = findViewById(R.id.organic_composer);
organicComposer.setOnClickListener(view -> launchPicker());
}
示例4: onCreate
import com.twitter.sdk.android.tweetcomposer.TweetComposer; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TwitterAuthConfig authConfig = new TwitterAuthConfig(TWITTER_KEY, TWITTER_SECRET);
Fabric.with(this, new Twitter(authConfig));
Fabric.with(this, new TweetComposer());
setContentView(R.layout.activity_splash_screen);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
Intent accountPortalIntent = new Intent(SplashScreen.this, MainActivity.class);
startActivity(accountPortalIntent);
finish();
}
}, SPLASH_TIME_OUT);
PreferencesLayer.initialize(getSharedPreferences("prefs", Context.MODE_PRIVATE));
String id = PreferencesLayer.getInstance().getKey();
Util.phoneNumbers = PreferencesLayer.getInstance().getPhoneNumbers();
Util.emails = PreferencesLayer.getInstance().getEmails();
if (id.equals("")) {
new RegisterTask().execute();
}
}
示例5: shareTwitter
import com.twitter.sdk.android.tweetcomposer.TweetComposer; //导入依赖的package包/类
private void shareTwitter(){
Uri path = Uri.parse("android.resource://net.geekstools.floatshort.PRO/" + R.drawable.ic_launcher_pro_marsala);
URL url = null;
try {
url = new URL(getString(R.string.link_shortcuts_pro));
} catch (MalformedURLException e) {
e.printStackTrace();
}
TweetComposer.Builder builder = new TweetComposer.Builder(this)
.url(url)
.text("@GeeksEmpire" + "\n" + getString(R.string.invitation_message)
+ "\n" + "#GeeksEmpire")
.image(path);
builder.show();
}
示例6: onCreate
import com.twitter.sdk.android.tweetcomposer.TweetComposer; //导入依赖的package包/类
@Override
public void onCreate() {
super.onCreate();
TwitterAuthConfig authConfig = new TwitterAuthConfig(TWITTER_KEY, TWITTER_SECRET);
// Fabric.with(this, new TwitterCore(authConfig), new Digits());
Fabric.with(this, new TwitterCore(authConfig),new TweetComposer());
}
示例7: shareOnTwitter
import com.twitter.sdk.android.tweetcomposer.TweetComposer; //导入依赖的package包/类
/**
* Shares the app on Twitter
*/
private void shareOnTwitter() {
try {
new TweetComposer.Builder(this)
.text(getString(R.string.social_twitter_message_android, "Android"))
.url(new URL(getString(R.string.social_link_android)))
.show();
} catch (MalformedURLException e) {
Timber.e(e, "Twitter URL malformed");
}
}
示例8: randomPost
import com.twitter.sdk.android.tweetcomposer.TweetComposer; //导入依赖的package包/类
public void randomPost() {
Toast.makeText(this, "random post selected", Toast.LENGTH_SHORT).show();
String tag = "@";
String[] people = getResources().getStringArray(R.array.twitter_names);
String person = people[randomInt(people.length)];
String[] messages = getResources().getStringArray(R.array.twitter);
String message = " " + messages[randomInt(messages.length)];
String post = tag + person + message;
TweetComposer.Builder builder = new TweetComposer.Builder(this)
.text(post);
builder.show();
new UpdateMessages().execute();
}
示例9: tweet
import com.twitter.sdk.android.tweetcomposer.TweetComposer; //导入依赖的package包/类
private static void tweet(){
TweetComposer.Builder builder = new TweetComposer.Builder(mActivity)
.text(mMediaContent.getTitle() + " - " + mMediaContent.getDescription());
builder.show();
}
示例10: onCreate
import com.twitter.sdk.android.tweetcomposer.TweetComposer; //导入依赖的package包/类
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TwitterAuthConfig authConfig = new TwitterAuthConfig(TWITTER_KEY, TWITTER_SECRET);
Fabric.with(this, new Twitter(authConfig));
Fabric.with(this, new TweetComposer(), new Twitter(authConfig));
final Intent i = new Intent(this, SelectMatrixOrNew.class); // Move to the bacon activity!
DBManager DBmgr = new DBManager(this);
ArrayList<String> matrixNames = DBmgr.getMatrixNames();
setTheme(android.R.style.Theme_Holo);
setContentView(R.layout.activity_welcome_screen);
if (matrixNames.size() != 0){
// When it's a repeat visit Let's make a little runnable saying we're loading and meanwhile load the other activity
// Though, generally this is too fast to be seen so it looks like we are jumping to the selection screen.
Runnable r = new Runnable() {
@Override
public void run() {
Message waitMsg = new Message();
Bundle contentMsg = new Bundle();
contentMsg.putString("status", "DirectionField\nLoading....");
waitMsg.setData(contentMsg);
handleTextChange.sendMessage(waitMsg);
}
};
Thread loading = new Thread(r); // calls the run method on the r Runnable object
loading.start();
startActivity(i);
} else {
DBManager MatrixDB = new DBManager(this); // Don't do anything with it though... just creating the first association with it
// Let's display something on the screen when it's the first time
RelativeLayout.LayoutParams layoutRel = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
layoutRel.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
layoutRel.addRule(RelativeLayout.CENTER_HORIZONTAL);
final Button clickToContinue = new Button(this);
clickToContinue.setText("Click to load");
RelativeLayout welcomeLayout = (RelativeLayout)findViewById(R.id.welcomeLayout);
welcomeLayout.addView(clickToContinue, layoutRel); // insert the button into the view and position it according to the rules
clickToContinue.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(i);
}
});
}
}
示例11: onCreate
import com.twitter.sdk.android.tweetcomposer.TweetComposer; //导入依赖的package包/类
@Override
public void onCreate() {
super.onCreate();
// Timber
if (BuildConfig.DEBUG) {
Timber.plant(new Timber.DebugTree());
}
if (BuildConfig.REPORT_CRASHES) {
Timber.plant(new ProductionTree() {
@Override
protected void log(String message) {
Crashlytics.log(message);
}
@Override
protected void logException(Throwable t) {
//Don't log SocketTimeoutExceptions
if (!(t instanceof SocketTimeoutException)) {
Crashlytics.logException(t);
}
}
});
}
// Fabric: Twitter, Crashlytics
TwitterAuthConfig authConfig = new TwitterAuthConfig(BuildConfig.TWITTER_KEY,
BuildConfig.TWITTER_SECRET);
@SuppressWarnings("PointlessBooleanExpression")
Crashlytics crashlytics = new Crashlytics.Builder().core(new CrashlyticsCore.Builder()
.disabled(!BuildConfig.REPORT_CRASHES).build()).build();
Fabric.with(this, new Twitter(authConfig), new TweetComposer(), crashlytics);
// Android ThreeTen
AndroidThreeTen.init(this);
// Dagger
component = DaggerBaseComponent.builder()
.appModule(new AppModule(this))
.build();
component.inject(this);
// Hawk
Hawk.init(this).build();
// DBFlow
FlowManager.init(new FlowConfig.Builder(this).build());
// FormGenerator
int padding = getResources().getDimensionPixelOffset(R.dimen.padding_small);
FormGenerator.set(new FormGenerator.Builder()
.setDefaultBackground(R.drawable.transparent_redpressed)
.setDefaultDrawablePaddingSize(padding)
.setDefaultPaddingSize(padding)
.setDefaultIconColor(ContextCompat.getColor(this, R.color.red)));
}
示例12: doInBackground
import com.twitter.sdk.android.tweetcomposer.TweetComposer; //导入依赖的package包/类
@Override
protected Boolean doInBackground(View... views) {
final View poem = views[0];
boolean result = false;
if (App.isExternalStorageWritable()) {
// generating image
final Bitmap bitmap = Bitmap.createBitmap(
getResources().getDimensionPixelSize(R.dimen.share_width_px),
getResources().getDimensionPixelSize(R.dimen.share_height_px),
Bitmap.Config.ARGB_8888);
final Canvas canvas = new Canvas(bitmap);
poem.draw(canvas);
final File picFile = App.getPoemFile("poem_" + poem.getTag() + ".jpg");
try {
picFile.createNewFile();
final FileOutputStream picOut = new FileOutputStream(picFile);
final boolean saved = bitmap.compress(Bitmap.CompressFormat.JPEG, 90, picOut);
if (saved) {
final CharSequence hashtag
= ((TextView) poem.findViewById(R.id.poem_theme)).getText();
// create Uri from local image file://<absolute path>
final Uri imageUri = Uri.fromFile(picFile);
final TweetComposer.Builder builder
= new TweetComposer.Builder(PoemHistoryActivity.this)
.text(getApplicationContext().getResources()
.getString(R.string.share_poem_tweet_text) + " " + hashtag)
.image(imageUri);
builder.show();
result = true;
} else {
Crashlytics.log(Log.ERROR, TAG, "Error when trying to save Bitmap of poem");
Toast.makeText(getApplicationContext(),
getResources().getString(R.string.toast_share_error),
Toast.LENGTH_SHORT).show();
}
picOut.close();
} catch (IOException e) {
Toast.makeText(getApplicationContext(),
getResources().getString(R.string.toast_share_error),
Toast.LENGTH_SHORT).show();
Crashlytics.logException(e);
e.printStackTrace();
}
poem.destroyDrawingCache();
} else {
Toast.makeText(getApplicationContext(),
getResources().getString(R.string.toast_share_error),
Toast.LENGTH_SHORT).show();
Crashlytics.log(Log.ERROR, TAG, "External Storage not writable");
}
return result;
}