use of net.dean.jraw.managers.InboxManager in project Slide by ccrama.
the class Inbox method onOptionsItemSelected.
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch(item.getItemId()) {
case (R.id.home):
onBackPressed();
break;
case (R.id.notifs):
LayoutInflater inflater = getLayoutInflater();
final View dialoglayout = inflater.inflate(R.layout.inboxfrequency, null);
SettingsGeneral.setupNotificationSettings(dialoglayout, Inbox.this);
break;
case (R.id.compose):
Intent i = new Intent(Inbox.this, SendMessage.class);
startActivity(i);
break;
case (R.id.read):
changed = false;
new AsyncTask<Void, Void, Void>() {
@Override
protected Void doInBackground(Void... params) {
try {
new InboxManager(Authentication.reddit).setAllRead();
changed = true;
} catch (Exception ignored) {
ignored.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(Void aVoid) {
if (changed) {
// restart the fragment
adapter.notifyDataSetChanged();
try {
final int CURRENT_TAB = tabs.getSelectedTabPosition();
adapter = new OverviewPagerAdapter(getSupportFragmentManager());
pager.setAdapter(adapter);
tabs.setupWithViewPager(pager);
scrollToTabAfterLayout(CURRENT_TAB);
pager.setCurrentItem(CURRENT_TAB);
} catch (Exception e) {
}
}
}
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
break;
}
return super.onOptionsItemSelected(item);
}
use of net.dean.jraw.managers.InboxManager in project Slide by ccrama.
the class MarkAsReadService method onHandleIntent.
@Override
protected void onHandleIntent(Intent intent) {
NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
manager.cancel(intent.getIntExtra(NOTIFICATION_ID, -1));
String[] messages = null;
Bundle extras = intent.getExtras();
if (extras != null)
messages = extras.getStringArray(CheckForMail.MESSAGE_EXTRA);
InboxManager inboxManager = new InboxManager(Authentication.reddit);
if (messages != null && NetworkUtil.isConnected(getBaseContext())) {
for (String message : messages) {
try {
inboxManager.setRead(message, true);
} catch (NetworkException e) {
e.printStackTrace();
return;
}
}
}
}
Aggregations