Search in sources :

Example 1 with AccountsAdapter

use of com.winsonchiu.reader.accounts.AccountsAdapter in project Reader by TheKeeperOfPie.

the class ActivityMain method inflateNavigationDrawer.

private void inflateNavigationDrawer() {
    // TODO: Adhere to guidelines by making the increment 56dp on mobile and 64dp on tablet
    float standardIncrement = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 56, getResources().getDisplayMetrics());
    float screenWidth = getResources().getDisplayMetrics().widthPixels;
    float navigationWidth = screenWidth - UtilsTheme.getAttributeDimension(this, R.attr.actionBarSize, standardIncrement);
    if (navigationWidth > standardIncrement * 6) {
        navigationWidth = standardIncrement * 6;
    }
    layoutNavigation.getLayoutParams().width = (int) navigationWidth;
    textAccountName.setTextColor(colorFilterPrimary.getColor());
    textAccountInfo.setTextColor(colorFilterPrimary.getColor());
    buttonAccounts.setColorFilter(colorFilterPrimary);
    View.OnClickListener onClickListener = v -> setAccountsVisible(!accountsVisible);
    textAccountName.setOnClickListener(onClickListener);
    textAccountInfo.setOnClickListener(onClickListener);
    buttonAccounts.setOnClickListener(onClickListener);
    adapterAccounts = new AccountsAdapter(colorFilterPrimary.getColor(), this);
    recyclerAccounts.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
    recyclerAccounts.setAdapter(adapterAccounts);
    resetAccountList();
    final GestureDetectorCompat gestureDetector = new GestureDetectorCompat(this, new GestureDetector.SimpleOnGestureListener() {

        @Override
        public boolean onDoubleTap(MotionEvent e) {
            loadHeaderImage(true);
            return true;
        }

        @Override
        public boolean onSingleTapConfirmed(MotionEvent e) {
            String permalink = sharedPreferences.getString(AppSettings.HEADER_PERMALINK, "");
            if (!TextUtils.isEmpty(permalink)) {
                Intent intentActivity = new Intent(ActivityMain.this, ActivityMain.class);
                intentActivity.setAction(Intent.ACTION_VIEW);
                intentActivity.setData(Uri.parse(Reddit.BASE_URL + permalink));
                startActivity(intentActivity);
                return true;
            }
            return super.onSingleTapConfirmed(e);
        }
    });
    // Add an empty view to remove extra margin on top
    viewNavigation.addHeaderView(new View(this));
    viewNavigation.setNavigationItemSelectedListener(menuItem -> {
        loadId = menuItem.getItemId();
        layoutDrawer.closeDrawer(GravityCompat.START);
        return true;
    });
    scrollHeaderVertical.setDispatchTouchListener((v, event) -> {
        gestureDetector.onTouchEvent(event);
        switch(MotionEventCompat.getActionMasked(event)) {
            case MotionEvent.ACTION_DOWN:
                layoutDrawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_OPEN);
                break;
            case MotionEvent.ACTION_UP:
            case MotionEvent.ACTION_CANCEL:
                layoutDrawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);
                break;
        }
        return false;
    });
    loadHeaderImage(false);
}
Also used : Bundle(android.os.Bundle) Uri(android.net.Uri) ImageView(android.widget.ImageView) CustomTabsIntent(android.support.customtabs.CustomTabsIntent) TaskStackBuilder(android.support.v4.app.TaskStackBuilder) FragmentReply(com.winsonchiu.reader.comments.FragmentReply) Source(com.winsonchiu.reader.comments.Source) UtilsJson(com.winsonchiu.reader.utils.UtilsJson) Drawable(android.graphics.drawable.Drawable) UtilsAnimation(com.winsonchiu.reader.utils.UtilsAnimation) HorizontalScrollView(android.widget.HorizontalScrollView) Reddit(com.winsonchiu.reader.data.reddit.Reddit) EventListenerBase(com.winsonchiu.reader.utils.EventListenerBase) Handler(android.os.Handler) CustomTabsSession(android.support.customtabs.CustomTabsSession) Schedulers(rx.schedulers.Schedulers) JsonNode(com.fasterxml.jackson.databind.JsonNode) Log(android.util.Log) AccountManager(android.accounts.AccountManager) AdapterCommentList(com.winsonchiu.reader.comments.AdapterCommentList) Account(android.accounts.Account) ContextCompat(android.support.v4.content.ContextCompat) ActivityCompat(android.support.v4.app.ActivityCompat) AccountManagerFuture(android.accounts.AccountManagerFuture) UtilsColor(com.winsonchiu.reader.utils.UtilsColor) AccountManagerCallback(android.accounts.AccountManagerCallback) Html(android.text.Html) Time(com.winsonchiu.reader.data.reddit.Time) FragmentProfile(com.winsonchiu.reader.profile.FragmentProfile) ControllerHistory(com.winsonchiu.reader.history.ControllerHistory) GestureDetector(android.view.GestureDetector) ButterKnife(butterknife.ButterKnife) Environment(android.os.Environment) BitmapFactory(android.graphics.BitmapFactory) NonNull(android.support.annotation.NonNull) Receiver(com.winsonchiu.reader.inbox.Receiver) ComponentStatic(com.winsonchiu.reader.dagger.components.ComponentStatic) ControllerInbox(com.winsonchiu.reader.inbox.ControllerInbox) Toast(android.widget.Toast) RedditOpenHelper(com.winsonchiu.reader.data.database.reddit.RedditOpenHelper) Menu(android.view.Menu) Link(com.winsonchiu.reader.data.reddit.Link) DrawerLayout(android.support.v4.widget.DrawerLayout) ComponentName(android.content.ComponentName) FileOutputStream(java.io.FileOutputStream) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) TextUtils(android.text.TextUtils) FinalizingSubscriber(com.winsonchiu.reader.rx.FinalizingSubscriber) IOException(java.io.IOException) Thing(com.winsonchiu.reader.data.reddit.Thing) FragmentSearch(com.winsonchiu.reader.search.FragmentSearch) File(java.io.File) RecyclerView(android.support.v7.widget.RecyclerView) AlertDialog(android.support.v7.app.AlertDialog) SharedPreferences(android.content.SharedPreferences) TypedValue(android.util.TypedValue) ThemeColor(com.winsonchiu.reader.theme.ThemeColor) UtilsImage(com.winsonchiu.reader.utils.UtilsImage) UtilsTheme(com.winsonchiu.reader.utils.UtilsTheme) CustomTabsCallback(android.support.customtabs.CustomTabsCallback) NavigationView(android.support.design.widget.NavigationView) ImageButton(android.widget.ImageButton) Page(com.winsonchiu.reader.data.Page) ControllerCommentsTop(com.winsonchiu.reader.comments.ControllerCommentsTop) Historian(com.winsonchiu.reader.history.Historian) ActivitySettings(com.winsonchiu.reader.settings.ActivitySettings) PackageManager(android.content.pm.PackageManager) ControllerLinks(com.winsonchiu.reader.links.ControllerLinks) URL(java.net.URL) AndroidSchedulers(rx.android.schedulers.AndroidSchedulers) ImageDownload(com.winsonchiu.reader.utils.ImageDownload) BindView(butterknife.BindView) Browser(android.provider.Browser) MotionEventCompat(android.support.v4.view.MotionEventCompat) Picasso(com.squareup.picasso.Picasso) ControllerProfile(com.winsonchiu.reader.profile.ControllerProfile) CustomTabsServiceConnection(android.support.customtabs.CustomTabsServiceConnection) Target(com.squareup.picasso.Target) View(android.view.View) CustomTabsClient(android.support.customtabs.CustomTabsClient) ControllerSearch(com.winsonchiu.reader.search.ControllerSearch) AccountsAdapter(com.winsonchiu.reader.accounts.AccountsAdapter) ScrollViewHeader(com.winsonchiu.reader.views.ScrollViewHeader) FragmentInbox(com.winsonchiu.reader.inbox.FragmentInbox) PorterDuff(android.graphics.PorterDuff) ComponentActivity(com.winsonchiu.reader.dagger.components.ComponentActivity) Observer(rx.Observer) FragmentComments(com.winsonchiu.reader.comments.FragmentComments) UtilsReddit(com.winsonchiu.reader.utils.UtilsReddit) AppCompatActivity(android.support.v7.app.AppCompatActivity) ViewGroup(android.view.ViewGroup) DownloadManager(android.app.DownloadManager) List(java.util.List) TextView(android.widget.TextView) Themer(com.winsonchiu.reader.theme.Themer) Replyable(com.winsonchiu.reader.data.reddit.Replyable) RelativeLayout(android.widget.RelativeLayout) Seat(jp.wasabeef.takt.Seat) YouTubePlayerSupportFragment(com.google.android.youtube.player.YouTubePlayerSupportFragment) ActivityManager(android.app.ActivityManager) Context(android.content.Context) Subreddit(com.winsonchiu.reader.data.reddit.Subreddit) AdapterLink(com.winsonchiu.reader.links.AdapterLink) UtilsRx(com.winsonchiu.reader.utils.UtilsRx) Intent(android.content.Intent) FragmentThreadList(com.winsonchiu.reader.links.FragmentThreadList) ObserverNext(com.winsonchiu.reader.rx.ObserverNext) Takt(jp.wasabeef.takt.Takt) MenuItem(android.view.MenuItem) FragmentHistory(com.winsonchiu.reader.history.FragmentHistory) Observable(rx.Observable) GravityCompat(android.support.v4.view.GravityCompat) Inject(javax.inject.Inject) MotionEvent(android.view.MotionEvent) Build(android.os.Build) AlarmManager(android.app.AlarmManager) URLUtil(android.webkit.URLUtil) MalformedURLException(java.net.MalformedURLException) LayoutInflater(android.view.LayoutInflater) Sort(com.winsonchiu.reader.data.reddit.Sort) Listing(com.winsonchiu.reader.data.reddit.Listing) Color(android.graphics.Color) Bitmap(android.graphics.Bitmap) GestureDetectorCompat(android.support.v4.view.GestureDetectorCompat) Callback(com.squareup.picasso.Callback) Activity(android.app.Activity) FragmentTransaction(android.support.v4.app.FragmentTransaction) Collections(java.util.Collections) Resources(android.content.res.Resources) CustomColorFilter(com.winsonchiu.reader.utils.CustomColorFilter) GestureDetector(android.view.GestureDetector) CustomTabsIntent(android.support.customtabs.CustomTabsIntent) Intent(android.content.Intent) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) ImageView(android.widget.ImageView) HorizontalScrollView(android.widget.HorizontalScrollView) RecyclerView(android.support.v7.widget.RecyclerView) NavigationView(android.support.design.widget.NavigationView) BindView(butterknife.BindView) View(android.view.View) TextView(android.widget.TextView) GestureDetectorCompat(android.support.v4.view.GestureDetectorCompat) MotionEvent(android.view.MotionEvent) AccountsAdapter(com.winsonchiu.reader.accounts.AccountsAdapter)

Aggregations

Account (android.accounts.Account)1 AccountManager (android.accounts.AccountManager)1 AccountManagerCallback (android.accounts.AccountManagerCallback)1 AccountManagerFuture (android.accounts.AccountManagerFuture)1 Activity (android.app.Activity)1 ActivityManager (android.app.ActivityManager)1 AlarmManager (android.app.AlarmManager)1 DownloadManager (android.app.DownloadManager)1 ComponentName (android.content.ComponentName)1 Context (android.content.Context)1 Intent (android.content.Intent)1 SharedPreferences (android.content.SharedPreferences)1 PackageManager (android.content.pm.PackageManager)1 Resources (android.content.res.Resources)1 Bitmap (android.graphics.Bitmap)1 BitmapFactory (android.graphics.BitmapFactory)1 Color (android.graphics.Color)1 PorterDuff (android.graphics.PorterDuff)1 Drawable (android.graphics.drawable.Drawable)1 Uri (android.net.Uri)1