Example usage for android.support.v4.content.res ResourcesCompat getDrawable

List of usage examples for android.support.v4.content.res ResourcesCompat getDrawable

Introduction

In this page you can find the example usage for android.support.v4.content.res ResourcesCompat getDrawable.

Prototype

public static Drawable getDrawable(Resources resources, int i, Theme theme) throws NotFoundException 

Source Link

Usage

From source file:com.arlib.floatingsearchviewdemo.MainActivity.java

private void setupFloatingSearch() {
    mSearchView.setOnQueryChangeListener(new FloatingSearchView.OnQueryChangeListener() {

        @Override//from www.ja v  a 2 s . c  o  m
        public void onSearchTextChanged(String oldQuery, final String newQuery) {

            if (!oldQuery.equals("") && newQuery.equals("")) {
                mSearchView.clearSuggestions();
            } else {

                //this shows the top left circular progress
                //you can call it where ever you want, but
                //it makes sense to do it when loading something in
                //the background.
                mSearchView.showProgress();

                //simulates a query call to a data source
                //with a new query.
                DataHelper.findSuggestions(MainActivity.this, newQuery, 5, FIND_SUGGESTION_SIMULATED_DELAY,
                        new DataHelper.OnFindSuggestionsListener() {

                            @Override
                            public void onResults(List<ColorSuggestion> results) {

                                //this will swap the data and
                                //render the collapse/expand animations as necessary
                                mSearchView.swapSuggestions(results);

                                //let the users know that the background
                                //process has completed
                                mSearchView.hideProgress();
                            }
                        });
            }

            Log.d(TAG, "onSearchTextChanged()");
        }
    });

    mSearchView.setOnSearchListener(new FloatingSearchView.OnSearchListener() {
        @Override
        public void onSuggestionClicked(SearchSuggestion searchSuggestion) {

            ColorSuggestion colorSuggestion = (ColorSuggestion) searchSuggestion;
            DataHelper.findColors(MainActivity.this, colorSuggestion.getBody(),
                    new DataHelper.OnFindColorsListener() {

                        @Override
                        public void onResults(List<ColorWrapper> results) {
                            mSearchResultsAdapter.swapData(results);
                        }

                    });
            Log.d(TAG, "onSuggestionClicked()");
        }

        @Override
        public void onSearchAction(String query) {

            DataHelper.findColors(MainActivity.this, query, new DataHelper.OnFindColorsListener() {

                @Override
                public void onResults(List<ColorWrapper> results) {
                    mSearchResultsAdapter.swapData(results);
                }

            });
            Log.d(TAG, "onSearchAction()");
        }
    });

    mSearchView.setOnFocusChangeListener(new FloatingSearchView.OnFocusChangeListener() {
        @Override
        public void onFocus() {
            mSearchView.clearQuery();

            //show suggestions when search bar gains focus (typically history suggestions)
            mSearchView.swapSuggestions(DataHelper.getHistory(MainActivity.this, 3));

            Log.d(TAG, "onFocus()");
        }

        @Override
        public void onFocusCleared() {

            Log.d(TAG, "onFocusCleared()");
        }
    });

    //handle menu clicks the same way as you would
    //in a regular activity
    mSearchView.setOnMenuItemClickListener(new FloatingSearchView.OnMenuItemClickListener() {
        @Override
        public void onActionMenuItemSelected(MenuItem item) {

            if (item.getItemId() == R.id.action_change_colors) {

                mIsDarkSearchTheme = true;

                //demonstrate setting colors for items
                mSearchView.setBackgroundColor(Color.parseColor("#787878"));
                mSearchView.setViewTextColor(Color.parseColor("#e9e9e9"));
                mSearchView.setHintTextColor(Color.parseColor("#e9e9e9"));
                mSearchView.setActionMenuOverflowColor(Color.parseColor("#e9e9e9"));
                mSearchView.setMenuItemIconColor(Color.parseColor("#e9e9e9"));
                mSearchView.setLeftActionIconColor(Color.parseColor("#e9e9e9"));
                mSearchView.setClearBtnColor(Color.parseColor("#e9e9e9"));
                mSearchView.setDividerColor(Color.parseColor("#BEBEBE"));
                mSearchView.setLeftActionIconColor(Color.parseColor("#e9e9e9"));
            } else {

                //just print action
                Toast.makeText(getApplicationContext(), item.getTitle(), Toast.LENGTH_SHORT).show();
            }

        }
    });

    //use this listener to listen to menu clicks when app:floatingSearch_leftAction="showHamburger"
    mSearchView.setOnLeftMenuClickListener(new FloatingSearchView.OnLeftMenuClickListener() {
        @Override
        public void onMenuOpened() {

            Log.d(TAG, "onMenuOpened()");
            mDrawerLayout.openDrawer(GravityCompat.START);
        }

        @Override
        public void onMenuClosed() {
            Log.d(TAG, "onMenuClosed()");
        }
    });

    //use this listener to listen to menu clicks when app:floatingSearch_leftAction="showHome"
    mSearchView.setOnHomeActionClickListener(new FloatingSearchView.OnHomeActionClickListener() {
        @Override
        public void onHomeClicked() {

            Log.d(TAG, "onHomeClicked()");
        }
    });

    /*
     * Here you have access to the left icon and the text of a given suggestion
     * item after as it is bound to the suggestion list. You can utilize this
     * callback to change some properties of the left icon and the text. For example, you
     * can load the left icon images using your favorite image loading library, or change text color.
     *
     *
     * Important:
     * Keep in mind that the suggestion list is a RecyclerView, so views are reused for different
     * items in the list.
     */
    mSearchView.setOnBindSuggestionCallback(new SearchSuggestionsAdapter.OnBindSuggestionCallback() {
        @Override
        public void onBindSuggestion(View suggestionView, ImageView leftIcon, TextView textView,
                SearchSuggestion item, int itemPosition) {
            ColorSuggestion colorSuggestion = (ColorSuggestion) item;

            String textColor = mIsDarkSearchTheme ? "#ffffff" : "#000000";
            String textLight = mIsDarkSearchTheme ? "#bfbfbf" : "#787878";

            if (colorSuggestion.getIsHistory()) {
                leftIcon.setImageDrawable(
                        ResourcesCompat.getDrawable(getResources(), R.drawable.ic_history_black_24dp, null));

                Util.setIconColor(leftIcon, Color.parseColor(textColor));
                leftIcon.setAlpha(.36f);
            } else {
                leftIcon.setAlpha(0.0f);
                leftIcon.setImageDrawable(null);
            }

            textView.setTextColor(Color.parseColor(textColor));
            String text = colorSuggestion.getBody().replaceFirst(mSearchView.getQuery(),
                    "<font color=\"" + textLight + "\">" + mSearchView.getQuery() + "</font>");
            textView.setText(Html.fromHtml(text));
        }

    });

    //listen for when suggestion list expands/shrinks in order to move down/up the
    //search results list
    mSearchView.setOnSuggestionsListHeightChanged(new FloatingSearchView.OnSuggestionsListHeightChanged() {
        @Override
        public void onSuggestionsListHeightChanged(float newHeight) {
            mSearchResultsList.setTranslationY(newHeight);
        }
    });
}

From source file:com.owncloud.android.utils.ThemeUtils.java

public static Drawable tintDrawable(@DrawableRes int id, int color) {
    Drawable drawable = ResourcesCompat.getDrawable(MainApp.getAppContext().getResources(), id, null);

    return tintDrawable(drawable, color);
}

From source file:com.camnter.easyrecyclerviewsidebar.EasyRecyclerViewSidebar.java

private void setPaintShader(@NonNull EasyImageSection imageSection) {
    Drawable drawable;//from   w ww.  j a  v  a 2s.c  o  m
    if (imageSection.drawable == null && imageSection.resId >= 0) {
        drawable = ResourcesCompat.getDrawable(this.getResources(), imageSection.resId, null);
    } else {
        drawable = imageSection.drawable;
    }
    if (drawable == null)
        return;

    Bitmap bitmap = this.drawableToBitmap(drawable);
    BitmapShader sectionBitmapShader = new BitmapShader(bitmap, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);
    float scale;
    scale = Math.max(this.letterSize * 1.0f / bitmap.getWidth(), this.letterSize * 1.0f / bitmap.getHeight());
    this.imageSectionMatrix.setScale(scale, scale);
    sectionBitmapShader.setLocalMatrix(this.imageSectionMatrix);
    Paint imagePaint = this.imagePaints.get(imageSection.hashCode());
    imagePaint.setShader(sectionBitmapShader);
}

From source file:org.getlantern.firetweet.util.CustomTabUtils.java

public static Drawable getTabIconDrawable(final Resources res, final Object iconObj) {
    if (res == null)
        return null;
    if (iconObj instanceof Integer) {
        try {/*from  www. j  av  a 2s.  c  o  m*/
            return ResourcesCompat.getDrawable(res, (Integer) iconObj, null);
        } catch (final Resources.NotFoundException e) {
            // Ignore.
        }
    } else if (iconObj instanceof Bitmap)
        return new BitmapDrawable(res, (Bitmap) iconObj);
    else if (iconObj instanceof Drawable)
        return (Drawable) iconObj;
    else if (iconObj instanceof File) {
        final Bitmap b = getTabIconFromFile((File) iconObj, res);
        if (b != null)
            return new BitmapDrawable(res, b);
    }
    return ResourcesCompat.getDrawable(res, R.drawable.ic_action_list, null);
}

From source file:com.makotogo.mobile.hoursdroid.HoursDetailFragment.java

private void configureProjectSpinner(View view) {
    final Spinner projectSpinner = (Spinner) view.findViewById(R.id.spinner_hours_detail_project);
    projectSpinner.setEnabled(isThisHoursRecordNotActive());
    if (isThisHoursRecordActive()) {
        projectSpinner.setBackground(ResourcesCompat.getDrawable(getResources(), R.drawable.no_border, null));
    } else {// ww  w  .j  a  v a2 s. co m
        projectSpinner
                .setBackground(ResourcesCompat.getDrawable(getResources(), R.drawable.rounded_border, null));
    }
    projectSpinner.setAdapter(new AbstractArrayAdapter(getActivity(), R.layout.project_list_row) {
        @Override
        protected ViewBinder<Project> createViewBinder() {
            return new ProjectViewBinder();
        }
    });
    projectSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            Project project = (Project) projectSpinner.getAdapter().getItem(position);
            if (project == Project.MANAGE_PROJECTS) {
                // Launch the Project List Screen
                Intent intent = new Intent(getActivity(), ProjectListActivity.class);
                intent.putExtra(ProjectListActivity.EXTRA_JOB, mHours.getJob());
                //Toast.makeText(getActivity(), "Launching ProjectListActivity (eventually)...", Toast.LENGTH_LONG).show();
                startActivityForResult(intent, REQUEST_CODE_MANAGE_PROJECTS);
            } else {
                // Active project has changed. Update the UI.
                mHours.setProject(project);
                updateUI();
            }
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
            // Nothing to do
        }
    });
}

From source file:me.ccrama.redditslide.DragSort.ReorderSubreddits.java

public void doShowSubs() {
    subs = new ArrayList<>(UserSubscriptions.getSubscriptions(this));
    recyclerView = (RecyclerView) findViewById(R.id.subslist);
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    recyclerView.setItemAnimator(null);//from ww  w .ja  v  a  2  s.c o  m

    DragSortRecycler dragSortRecycler = new DragSortRecycler();
    dragSortRecycler.setViewHandleId();
    dragSortRecycler.setFloatingAlpha();
    dragSortRecycler.setAutoScrollSpeed();
    dragSortRecycler.setAutoScrollWindow();

    dragSortRecycler.setOnItemMovedListener(new DragSortRecycler.OnItemMovedListener() {
        @Override
        public void onItemMoved(int from, int to) {
            String item = subs.remove(from);
            subs.add(to, item);
            adapter.notifyDataSetChanged();
        }
    });

    dragSortRecycler.setOnDragStateChangedListener(new DragSortRecycler.OnDragStateChangedListener() {
        @Override
        public void onDragStart() {
        }

        @Override
        public void onDragStop() {
        }
    });
    final FloatingActionsMenu fab = (FloatingActionsMenu) findViewById(R.id.add);

    {
        FloatingActionButton collection = (FloatingActionButton) findViewById(R.id.collection);
        Drawable icon = ResourcesCompat.getDrawable(getResources(), R.drawable.collection, null);
        collection.setIconDrawable(icon);
        collection.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                fab.collapse();
                if (UserSubscriptions.getMultireddits() != null
                        && !UserSubscriptions.getMultireddits().isEmpty()) {
                    new AlertDialogWrapper.Builder(ReorderSubreddits.this)
                            .setTitle(R.string.create_or_import_multi)
                            .setPositiveButton(R.string.btn_new, new DialogInterface.OnClickListener() {
                                @Override
                                public void onClick(DialogInterface dialog, int which) {
                                    doCollection();
                                }
                            }).setNegativeButton(R.string.btn_import_multi,
                                    new DialogInterface.OnClickListener() {
                                        @Override
                                        public void onClick(DialogInterface dialog, int which) {
                                            final String[] multis = new String[UserSubscriptions
                                                    .getMultireddits().size()];
                                            int i = 0;
                                            for (MultiReddit m : UserSubscriptions.getMultireddits()) {
                                                multis[i] = m.getDisplayName();
                                                i++;
                                            }
                                            MaterialDialog.Builder builder = new MaterialDialog.Builder(
                                                    ReorderSubreddits.this);
                                            builder.title(R.string.reorder_subreddits_title).items(multis)
                                                    .itemsCallbackSingleChoice(-1,
                                                            new MaterialDialog.ListCallbackSingleChoice() {
                                                                @Override
                                                                public boolean onSelection(
                                                                        MaterialDialog dialog, View itemView,
                                                                        int which, CharSequence text) {

                                                                    String name = multis[which];
                                                                    MultiReddit r = UserSubscriptions
                                                                            .getMultiredditByDisplayName(name);
                                                                    StringBuilder b = new StringBuilder();

                                                                    for (MultiSubreddit s : r.getSubreddits()) {
                                                                        b.append(s.getDisplayName());
                                                                        b.append("+");
                                                                    }
                                                                    int pos = addSubAlphabetically(
                                                                            MULTI_REDDIT + r.getDisplayName());
                                                                    UserSubscriptions.setSubNameToProperties(
                                                                            MULTI_REDDIT + r.getDisplayName(),
                                                                            b.toString());
                                                                    adapter.notifyDataSetChanged();
                                                                    recyclerView.smoothScrollToPosition(pos);
                                                                    return false;
                                                                }
                                                            })
                                                    .show();
                                        }
                                    })
                            .show();
                } else {
                    doCollection();
                }
            }
        });
    }
    {
        FloatingActionButton collection = (FloatingActionButton) findViewById(R.id.sub);
        Drawable icon = ResourcesCompat.getDrawable(getResources(), R.drawable.sub, null);
        collection.setIconDrawable(icon);
        collection.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                fab.collapse();
                MaterialDialog.Builder b = new MaterialDialog.Builder(ReorderSubreddits.this)
                        .title(R.string.reorder_add_or_search_subreddit).alwaysCallInputCallback()
                        .input(getString(R.string.reorder_subreddit_name), null, false,
                                new MaterialDialog.InputCallback() {
                                    @Override
                                    public void onInput(MaterialDialog dialog, CharSequence raw) {
                                        input = raw.toString();
                                    }
                                })
                        .positiveText(R.string.btn_add).onPositive(new MaterialDialog.SingleButtonCallback() {
                            @Override
                            public void onClick(MaterialDialog dialog, DialogAction which) {
                                new AsyncGetSubreddit().execute(input);
                            }
                        }).negativeText(R.string.btn_cancel)
                        .onNegative(new MaterialDialog.SingleButtonCallback() {
                            @Override
                            public void onClick(MaterialDialog dialog, DialogAction which) {

                            }
                        });
                b.show();
            }
        });
    }
    {
        FloatingActionButton collection = (FloatingActionButton) findViewById(R.id.domain);
        Drawable icon = ResourcesCompat.getDrawable(getResources(), R.drawable.link, null);
        collection.setIconDrawable(icon);
        collection.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                fab.collapse();
                new MaterialDialog.Builder(ReorderSubreddits.this).title(R.string.reorder_add_domain)
                        .alwaysCallInputCallback()
                        .input("example.com" + getString(R.string.reorder_domain_placeholder), null, false,
                                new MaterialDialog.InputCallback() {
                                    @Override
                                    public void onInput(MaterialDialog dialog, CharSequence raw) {
                                        input = raw.toString().replaceAll("\\s", ""); //remove whitespace from input
                                        if (input.contains(".")) {
                                            dialog.getActionButton(DialogAction.POSITIVE).setEnabled(true);
                                        } else {
                                            dialog.getActionButton(DialogAction.POSITIVE).setEnabled(false);
                                        }
                                    }
                                })
                        .positiveText(R.string.btn_add).inputRange(1, 35)
                        .onPositive(new MaterialDialog.SingleButtonCallback() {
                            @Override
                            public void onClick(MaterialDialog dialog, DialogAction which) {
                                try {
                                    String url = (input);

                                    List<String> sortedSubs = UserSubscriptions.sortNoExtras(subs);

                                    if (sortedSubs.equals(subs)) {
                                        subs.add(url);
                                        subs = UserSubscriptions.sortNoExtras(subs);
                                        adapter = new CustomAdapter(subs);
                                        recyclerView.setAdapter(adapter);
                                    } else {
                                        int pos = addSubAlphabetically(url);
                                        adapter.notifyDataSetChanged();
                                        recyclerView.smoothScrollToPosition(pos);
                                    }
                                } catch (Exception e) {
                                    e.printStackTrace();
                                    //todo make this better
                                    new AlertDialogWrapper.Builder(ReorderSubreddits.this)
                                            .setTitle(R.string.reorder_url_err)
                                            .setMessage(R.string.misc_please_try_again).show();

                                }
                            }

                        }).negativeText(R.string.btn_cancel)
                        .onNegative(new MaterialDialog.SingleButtonCallback() {
                            @Override
                            public void onClick(MaterialDialog dialog, DialogAction which) {

                            }
                        }).show();
            }
        });
    }
    recyclerView.addItemDecoration(dragSortRecycler);
    recyclerView.addOnItemTouchListener(dragSortRecycler);
    recyclerView.addOnScrollListener(dragSortRecycler.getScrollListener());
    dragSortRecycler.setViewHandleId();

    if (subs != null && !subs.isEmpty()) {
        adapter = new CustomAdapter(subs);
        //  adapter.setHasStableIds(true);
        recyclerView.setAdapter(adapter);
    } else {
        subs = new ArrayList<>();
    }

    recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            super.onScrolled(recyclerView, dx, dy);
            if (recyclerView.getScrollState() == RecyclerView.SCROLL_STATE_DRAGGING) {
                diff += dy;
            } else {
                diff = 0;
            }
            if (dy <= 0 && fab.getId() != 0) {

            } else {
                fab.collapse();
            }

        }
    });
}

From source file:com.taobao.weex.utils.ImgURIUtil.java

public static Drawable getDrawableFromLoaclSrc(Context context, Uri rewrited) {
    Resources resources = context.getResources();
    List<String> segments = rewrited.getPathSegments();
    if (segments.size() != 1) {
        WXLogUtils.e("Local src format is invalid.");
        return null;
    }/*from  ww w  . jav a  2  s  .  co m*/
    int id = resources.getIdentifier(segments.get(0), "drawable", context.getPackageName());
    return id == 0 ? null : ResourcesCompat.getDrawable(resources, id, null);
}

From source file:org.getlantern.firetweet.activity.support.SignInActivity.java

@Override
protected void onCreate(final Bundle savedInstanceState) {
    supportRequestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    super.onCreate(savedInstanceState);
    mPreferences = getSharedPreferences(SHARED_PREFERENCES_NAME, MODE_PRIVATE);
    mResolver = getContentResolver();//w w w  .j  a  v  a2  s .c o m
    mApplication = FiretweetApplication.getInstance(this);
    setContentView(R.layout.activity_sign_in);
    setSupportProgressBarIndeterminateVisibility(false);
    final long[] account_ids = getActivatedAccountIds(this);
    final ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(account_ids.length > 0);
    }

    if (savedInstanceState != null) {
        mAPIUrlFormat = savedInstanceState.getString(Accounts.API_URL_FORMAT);
        mAuthType = savedInstanceState.getInt(Accounts.AUTH_TYPE);
        mSameOAuthSigningUrl = savedInstanceState.getBoolean(Accounts.SAME_OAUTH_SIGNING_URL);
        mConsumerKey = trim(savedInstanceState.getString(Accounts.CONSUMER_KEY));
        mConsumerSecret = trim(savedInstanceState.getString(Accounts.CONSUMER_SECRET));
        mUsername = savedInstanceState.getString(Accounts.SCREEN_NAME);
        mPassword = savedInstanceState.getString(Accounts.PASSWORD);
        mAPIChangeTimestamp = savedInstanceState.getLong(EXTRA_API_LAST_CHANGE);
    }

    Typeface font = Typeface.createFromAsset(getAssets(), "fonts/ProximaNova-Semibold.ttf");

    mSigninSignupContainer.setOrientation(
            mAuthType == Accounts.AUTH_TYPE_TWIP_O_MODE ? LinearLayout.VERTICAL : LinearLayout.HORIZONTAL);

    final Resources resources = getResources();
    final ColorStateList color = ColorStateList.valueOf(resources.getColor(R.color.material_light_blue));

    mSignInButton.setTextColor(Color.parseColor("#38c6f3"));
    mSignInButton.setBackgroundColor(Color.parseColor("#E7E7E7"));
    mSignInButton.setBackgroundResource(R.drawable.sign_in_btn);
    mSignInButton.setTypeface(font);
    mSignUpButton.setTypeface(font);
    poweredByButton.setTypeface(font);

    autoTweetCheckBox = (CheckBox) findViewById(R.id.autotweet_checkbox);
    autoTweetText = (TextView) findViewById(R.id.should_send_autotweet);

    // don't display the auto tweet text on subsequent runs
    if (mPreferences.contains(APP_RAN_BEFORE)) {
        autoTweetCheckBox.setVisibility(View.GONE);
        autoTweetText.setVisibility(View.GONE);
    } else {
        // the checkbox color attribute isn't a simple attribute
        // we have to grab the default checkbox and apply a color filter
        int id = Resources.getSystem().getIdentifier("btn_check_holo_light", "drawable", "android");
        Drawable drawable = ResourcesCompat.getDrawable(getResources(), id, null);
        if (drawable != null) {
            drawable.setColorFilter(Color.parseColor("white"), PorterDuff.Mode.SRC_ATOP);
            autoTweetCheckBox.setButtonDrawable(drawable);
        }

        autoTweetText.setTypeface(font);
        autoTweetText.setTextColor(Color.parseColor("white"));
    }

    setSignInButton();
}

From source file:com.stepstone.stepper.StepperLayout.java

private void initNavigation() {
    mStepNavigation.setBackgroundResource(mBottomNavigationBackground);

    mBackNavigationButton.setText(mBackButtonText);
    mNextNavigationButton.setText(mNextButtonText);
    mCompleteNavigationButton.setText(mCompleteButtonText);

    //FIXME: 16/03/16 this is a workaround for tinting TextView's compound drawables on API 16-17 - when set in XML only the default color is used...
    Drawable chevronEndDrawable = ResourcesCompat.getDrawable(getContext().getResources(),
            R.drawable.ic_chevron_end, null);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        mNextNavigationButton.setCompoundDrawablesRelativeWithIntrinsicBounds(null, null, chevronEndDrawable,
                null);/*from ww  w.  j av  a2 s.  c  om*/
    } else {
        mNextNavigationButton.setCompoundDrawablesWithIntrinsicBounds(null, null, chevronEndDrawable, null);
    }

    TintUtil.tintTextView(mBackNavigationButton, mBackButtonColor);
    TintUtil.tintTextView(mNextNavigationButton, mNextButtonColor);
    TintUtil.tintTextView(mCompleteNavigationButton, mCompleteButtonColor);

    setBackgroundIfPresent(mBackButtonBackground, mBackNavigationButton);
    setBackgroundIfPresent(mNextButtonBackground, mNextNavigationButton);
    setBackgroundIfPresent(mCompleteButtonBackground, mCompleteNavigationButton);

    mBackNavigationButton.setOnClickListener(mOnBackClickListener);
    mNextNavigationButton.setOnClickListener(mOnNextClickListener);
    mCompleteNavigationButton.setOnClickListener(mOnCompleteClickListener);
}

From source file:com.mifos.mifosxdroid.online.ClientDetailsFragment.java

/**
 * Use this method to fetch and inflate client details
 * in the fragment/*from   w ww . j  a  v  a  2  s .com*/
 */
public void getClientDetails() {
    showProgress(true);
    App.apiManager.getClient(clientId, new Callback<Client>() {
        @Override
        public void success(final Client client, Response response) {
            /* Activity is null - Fragment has been detached; no need to do anything. */
            if (getActivity() == null)
                return;

            if (client != null) {
                setToolbarTitle(getString(R.string.client) + " - " + client.getLastname());
                tv_fullName.setText(client.getDisplayName());
                tv_accountNumber.setText(client.getAccountNo());
                tv_externalId.setText(client.getExternalId());
                if (TextUtils.isEmpty(client.getAccountNo()))
                    rowAccount.setVisibility(GONE);

                if (TextUtils.isEmpty(client.getExternalId()))
                    rowExternal.setVisibility(GONE);

                try {
                    List<Integer> dateObj = client.getActivationDate();
                    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd MMM yyyy");
                    Date date = simpleDateFormat.parse(DateHelper.getDateAsString(dateObj));
                    Locale currentLocale = getResources().getConfiguration().locale;
                    DateFormat df = DateFormat.getDateInstance(DateFormat.MEDIUM, currentLocale);
                    String dateString = df.format(date);
                    tv_activationDate.setText(dateString);

                    if (TextUtils.isEmpty(dateString))
                        rowActivation.setVisibility(GONE);

                } catch (IndexOutOfBoundsException e) {
                    Toast.makeText(getActivity(), getString(R.string.error_client_inactive), Toast.LENGTH_SHORT)
                            .show();
                    tv_activationDate.setText("");
                } catch (ParseException e) {
                    Log.d(TAG, e.getLocalizedMessage());
                }
                tv_office.setText(client.getOfficeName());

                if (TextUtils.isEmpty(client.getOfficeName()))
                    rowOffice.setVisibility(GONE);

                if (client.isImagePresent()) {
                    imageLoadingAsyncTask = new ImageLoadingAsyncTask();
                    imageLoadingAsyncTask.execute(client.getId());
                } else {
                    iv_clientImage.setImageDrawable(
                            ResourcesCompat.getDrawable(getResources(), R.drawable.ic_launcher, null));

                    pb_imageProgressBar.setVisibility(GONE);
                }

                iv_clientImage.setOnClickListener(new OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        PopupMenu menu = new PopupMenu(getActivity(), view);
                        menu.getMenuInflater().inflate(R.menu.client_image_popup, menu.getMenu());
                        menu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
                            @Override
                            public boolean onMenuItemClick(MenuItem menuItem) {
                                switch (menuItem.getItemId()) {
                                case R.id.client_image_capture:
                                    captureClientImage();
                                    break;
                                case R.id.client_image_remove:
                                    deleteClientImage();
                                    break;
                                default:
                                    Log.e("ClientDetailsFragment",
                                            "Unrecognized " + "client " + "image menu item");
                                }
                                return true;
                            }
                        });
                        menu.show();
                    }
                });
                showProgress(false);
                inflateClientsAccounts();
            }
        }

        @Override
        public void failure(RetrofitError retrofitError) {
            Toaster.show(rootView, "Client not found.");
            showProgress(false);
        }
    });
}