private void checkAndSendTagsIfWeCan() { SendTagsFragment sendTagsFragment = getSendTagsFragment(); if (sendTagsFragment.canSendTags()) { sendTagsFragment.submitTags( this, mIntTags.getText().toString().trim(), mStringTags.getText().toString().trim()); } }
/** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); // NetworkUtils.useSSL = true; // Register receivers for push notifications registerReceivers(); // Create and start push manager PushManager pushManager = new PushManager(this, APP_ID, SENDER_ID); pushManager.onStartup(this); // The commented code below shows how to use geo pushes // pushManager.startTrackingGeoPushes(); // The commented code below shows how to use local notifications // PushManager.clearLocalNotifications(this); // easy way // PushManager.scheduleLocalNotification(this, "Your pumpkins are ready!", 30); // expert mode // Bundle extras = new Bundle(); // extras.putString("b", "https://cp.pushwoosh.com/img/arello-logo.png"); // extras.putString("u", "50"); // PushManager.scheduleLocalNotification(this, "Your pumpkins are ready!", extras, 30); mGeneralStatus = (TextView) findViewById(R.id.general_status); mTagsStatus = (TextView) findViewById(R.id.status); mIntTags = (EditText) findViewById(R.id.tag_int); mStringTags = (EditText) findViewById(R.id.tag_string); checkMessage(getIntent()); mSubmitTagsButton = (Button) findViewById(R.id.submit_tags); mSubmitTagsButton.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { // PushManager.getTagsAsync(MainActivity.this, tagsListener); checkAndSendTagsIfWeCan(); } }); SendTagsFragment sendTagsFragment = getSendTagsFragment(); mTagsStatus.setText(sendTagsFragment.getSendTagsStatus()); mSubmitTagsButton.setEnabled(sendTagsFragment.canSendTags()); }
private SendTagsFragment getSendTagsFragment() { FragmentManager fragmentManager = getSupportFragmentManager(); SendTagsFragment sendTagsFragment = (SendTagsFragment) fragmentManager.findFragmentByTag(SEND_TAGS_STATUS_FRAGMENT_TAG); if (null == sendTagsFragment) { sendTagsFragment = new SendTagsFragment(); sendTagsFragment.setRetainInstance(true); fragmentManager .beginTransaction() .add(sendTagsFragment, SEND_TAGS_STATUS_FRAGMENT_TAG) .commit(); fragmentManager.executePendingTransactions(); } return sendTagsFragment; }