Search in sources :

Example 1 with ChangelogAdapter

use of com.klinker.android.twitter.adapters.ChangelogAdapter in project Talon-for-Twitter by klinker24.

the class SettingsLinkDrawerClickListener method onItemClick.

@Override
public void onItemClick(AdapterView parent, View view, int position, long id) {
    Intent intent;
    final int mPos = position;
    if (mPos < 2) {
        // one of the settings pages
        new Handler().postDelayed(new Runnable() {

            @Override
            public void run() {
                mDrawerLayout.closeDrawer(Gravity.START);
            }
        }, 300);
        viewPager.setCurrentItem(mPos + 7, true);
    } else if (mPos == 2) {
        // changelog
        final ListView list = new ListView(context);
        list.setDividerHeight(0);
        new AsyncTask<Spanned[], Void, Spanned[]>() {

            @Override
            public Spanned[] doInBackground(Spanned[]... params) {
                return XmlChangelogUtils.parse(context);
            }

            @Override
            public void onPostExecute(Spanned[] result) {
                list.setAdapter(new ChangelogAdapter(context, result));
            }
        }.execute();
        new AlertDialog.Builder(context).setTitle(R.string.changelog).setView(list).setPositiveButton(R.string.ok, null).show();
    } else if (mPos == 3) {
        // rate it option
        new Handler().postDelayed(new Runnable() {

            @Override
            public void run() {
                Uri uri = Uri.parse("market://details?id=" + context.getPackageName());
                Intent goToMarket = new Intent(Intent.ACTION_VIEW, uri);
                try {
                    context.startActivity(goToMarket);
                } catch (ActivityNotFoundException e) {
                    Toast.makeText(context, "Couldn't launch the market", Toast.LENGTH_SHORT).show();
                }
            }
        }, 200);
    }
}
Also used : AlertDialog(android.app.AlertDialog) AsyncTask(android.os.AsyncTask) Handler(android.os.Handler) Intent(android.content.Intent) Spanned(android.text.Spanned) Uri(android.net.Uri) ListView(android.widget.ListView) ActivityNotFoundException(android.content.ActivityNotFoundException) ChangelogAdapter(com.klinker.android.twitter.adapters.ChangelogAdapter)

Example 2 with ChangelogAdapter

use of com.klinker.android.twitter.adapters.ChangelogAdapter in project Talon-for-Twitter by klinker24.

the class SettingsActivity method onOptionsItemSelected.

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch(item.getItemId()) {
        case android.R.id.home:
            onBackPressed();
            return true;
        case R.id.menu_whats_new:
            final Context context = this;
            final ListView list = new ListView(this);
            list.setDividerHeight(0);
            new AsyncTask<Spanned[], Void, Spanned[]>() {

                @Override
                public Spanned[] doInBackground(Spanned[]... params) {
                    return XmlChangelogUtils.parse(context);
                }

                @Override
                public void onPostExecute(Spanned[] result) {
                    list.setAdapter(new ChangelogAdapter(context, result));
                }
            }.execute();
            new AlertDialog.Builder(this).setTitle(R.string.changelog).setView(list).setPositiveButton(R.string.ok, null).show();
            return true;
        case R.id.menu_rate_it:
            Uri uri = Uri.parse("market://details?id=" + getPackageName());
            Intent goToMarket = new Intent(Intent.ACTION_VIEW, uri);
            try {
                startActivity(goToMarket);
            } catch (ActivityNotFoundException e) {
                Toast.makeText(this, "Couldn't launch the market", Toast.LENGTH_SHORT).show();
            }
            return true;
        case R.id.menu_get_help:
            showSettings(8, getString(R.string.get_help_settings));
            return true;
        case R.id.menu_other_apps:
            showSettings(9, getString(R.string.other_apps));
            return true;
        default:
            return super.onOptionsItemSelected(item);
    }
}
Also used : Context(android.content.Context) ListView(android.widget.ListView) ActivityNotFoundException(android.content.ActivityNotFoundException) Intent(android.content.Intent) ChangelogAdapter(com.klinker.android.twitter.adapters.ChangelogAdapter) Spanned(android.text.Spanned) Uri(android.net.Uri)

Aggregations

ActivityNotFoundException (android.content.ActivityNotFoundException)2 Intent (android.content.Intent)2 Uri (android.net.Uri)2 Spanned (android.text.Spanned)2 ListView (android.widget.ListView)2 ChangelogAdapter (com.klinker.android.twitter.adapters.ChangelogAdapter)2 AlertDialog (android.app.AlertDialog)1 Context (android.content.Context)1 AsyncTask (android.os.AsyncTask)1 Handler (android.os.Handler)1