Example usage for android.graphics Typeface NORMAL

List of usage examples for android.graphics Typeface NORMAL

Introduction

In this page you can find the example usage for android.graphics Typeface NORMAL.

Prototype

int NORMAL

To view the source code for android.graphics Typeface NORMAL.

Click Source Link

Usage

From source file:com.crossconnect.activity.main.BibleTextFragment.java

private void loadSettings() {
    SharedPreferences appPreferences = PreferenceManager.getDefaultSharedPreferences(getActivity());
    // Now, we're going to check for the Text size variable and set the text
    // size/*from  w w w  . j av a  2 s  .c  om*/

    bibleTextView.setTextSize(
            Float.parseFloat(appPreferences.getString(getActivity().getString(R.string.text_size_key), "18")));

    int color = appPreferences.getInt(getActivity().getString(R.string.text_color_key), Color.BLACK);
    bibleTextView.setTextColor(color);

    try {
        //Set Custom font
        bibleTextView
                .setTypeface(
                        Typeface.createFromAsset(getActivity().getAssets(),
                                "fonts/" + appPreferences.getString(
                                        getActivity().getString(R.string.text_font_key), "Ubuntu-R.ttf")),
                        Typeface.NORMAL);
        //            this.setTypeface(Typeface.createFromAsset(ctx.getAssets(), "fonts/" + "Ubuntu-B.ttf"), Typeface.BOLD);
    } catch (Exception e) {
        //Custom font not found
        Log.e(TAG, "Font not found!", e);
    }

}

From source file:org.crossconnect.bible.activity.main.BibleTextFragment.java

private void loadSettings() {
    SharedPreferences appPreferences = PreferenceManager.getDefaultSharedPreferences(getActivity());
    // Now, we're going to check for the Text size variable and set the text
    // size//www.  j  av  a 2 s  .com

    bibleTextView.setTextSize(
            Float.parseFloat(appPreferences.getString(getActivity().getString(R.string.text_size_key), "18")));

    int color = appPreferences.getInt(getActivity().getString(R.string.text_color_key), Color.BLACK);
    bibleTextView.setTextColor(color);

    try {
        //Set Custom font
        bibleTextView
                .setTypeface(
                        Typeface.createFromAsset(getActivity().getAssets(),
                                "fonts/" + appPreferences.getString(
                                        getActivity().getString(R.string.text_font_key), "Ubuntu-R.ttf")),
                        Typeface.NORMAL);
        //            this.setTypeface(Typeface.createFromAsset(ctx.getAssets(), "fonts/" + "Ubuntu-B.ttf"), Typeface.BOLD);
    } catch (Exception e) {
        //Custom font not found
        Log.d(TAG, "Font not found!", e);
    }

}

From source file:com.groksolutions.grok.mobile.annotation.AnnotationListFragment.java

/**
 * Format annotation message body for list item display
 *
 * @param annotation The annotation to format
 *
 * @return The formatted annotation text suitable for use with {@link android.widget.TextView}
 *//*from  w  w  w  .  j av a  2s .  c  om*/
SpannableStringBuilder formatAnnotationBody(Annotation annotation) {
    int pos;

    // Format text
    SpannableStringBuilder text = new SpannableStringBuilder();

    // <br/> My Message
    pos = text.length();
    text.append(annotation.getMessage());
    text.setSpan(new RelativeSizeSpan(1.0f), pos, text.length(), 0);
    text.setSpan(new StyleSpan(Typeface.NORMAL), pos, text.length(), 0);

    // Attach hidden annotation ID to the text.
    // This ID is used by the actions attached to the list
    text.setSpan(new android.text.Annotation("id", annotation.getId()), 0, text.length(), 0);

    return text;
}

From source file:io.doist.datetimepicker.date.SimpleMonthView.java

/**
 * Sets up the text and style properties for painting.
 *///w ww  . j  ava2s .c  om
private void initView() {
    mMonthTitlePaint = new Paint();
    mMonthTitlePaint.setAntiAlias(true);
    mMonthTitlePaint.setColor(mNormalTextColor);
    mMonthTitlePaint.setTextSize(mMonthLabelTextSize);
    mMonthTitlePaint.setTypeface(Typeface.create(mMonthTitleTypeface, Typeface.BOLD));
    mMonthTitlePaint.setTextAlign(Align.CENTER);
    mMonthTitlePaint.setStyle(Style.FILL);
    mMonthTitlePaint.setFakeBoldText(true);

    mMonthDayLabelPaint = new Paint();
    mMonthDayLabelPaint.setAntiAlias(true);
    mMonthDayLabelPaint.setColor(mNormalTextColor);
    mMonthDayLabelPaint.setTextSize(mMonthDayLabelTextSize);
    mMonthDayLabelPaint.setTypeface(Typeface.create(mDayOfWeekTypeface, Typeface.NORMAL));
    mMonthDayLabelPaint.setTextAlign(Align.CENTER);
    mMonthDayLabelPaint.setStyle(Style.FILL);
    mMonthDayLabelPaint.setFakeBoldText(true);

    mDayNumberSelectedPaint = new Paint();
    mDayNumberSelectedPaint.setAntiAlias(true);
    mDayNumberSelectedPaint.setColor(mSelectedDayColor);
    mDayNumberSelectedPaint.setAlpha(SELECTED_CIRCLE_ALPHA);
    mDayNumberSelectedPaint.setTextAlign(Align.CENTER);
    mDayNumberSelectedPaint.setStyle(Style.FILL);
    mDayNumberSelectedPaint.setFakeBoldText(true);

    mDayNumberPaint = new Paint();
    mDayNumberPaint.setAntiAlias(true);
    mDayNumberPaint.setTextSize(mMiniDayNumberTextSize);
    mDayNumberPaint.setTextAlign(Align.CENTER);
    mDayNumberPaint.setStyle(Style.FILL);
    mDayNumberPaint.setFakeBoldText(false);

    mDayNumberDisabledPaint = new Paint();
    mDayNumberDisabledPaint.setAntiAlias(true);
    mDayNumberDisabledPaint.setColor(mDisabledTextColor);
    mDayNumberDisabledPaint.setTextSize(mMiniDayNumberTextSize);
    mDayNumberDisabledPaint.setTextAlign(Align.CENTER);
    mDayNumberDisabledPaint.setStyle(Style.FILL);
    mDayNumberDisabledPaint.setFakeBoldText(false);
}

From source file:com.maedi.user.godok.v1.viewpagerindicator.TabPageIndicator.java

@SuppressLint("ResourceAsColor")
private void changeTabLayout(int item, String title) {
    PagerAdapter adapter = mViewPager.getAdapter();
    final int tabCount = mTabLayout.getChildCount();
    for (int i = 0; i < tabCount; i++) {
        final View child = mTabLayout.getChildAt(i);

        if (i == 1)
            child.setBackgroundResource(R.drawable.tab_view);//child.setPadding(0, 0, 10, 0);//L,T,R,B
        ((TextView) child).setTypeface(Typeface.DEFAULT, Typeface.NORMAL);
        //((TextView) child).setTextColor(getResources().getColor(R.color.tab_button_text));
        ((TextView) child).setTextSize(15);
        ((TextView) child).setGravity(Gravity.CENTER);
        ((TextView) child).setTextColor(getResources().getColor(R.color.white));

        /*/*from w  ww .j a v a  2 s .co  m*/
         * for advance menu left selected
         * by medi
         */
        if (null != title && !title.equalsIgnoreCase("")) {
            CharSequence originalTitle = adapter.getPageTitle(i);
            ((TextView) child).setText(originalTitle);
        }

        final boolean isSelected = (i == item);
        child.setSelected(isSelected);
        if (isSelected) {
            animateToTab(item);
            ((TextView) child).setTypeface(Typeface.DEFAULT, Typeface.BOLD);
            //((TextView) child).setTextColor(getResources().getColor(R.color.tab_button_text_selected));

            if (null != title && !title.equalsIgnoreCase("")) {
                ((TextView) child).setText(title);
            }

        }
    }
}

From source file:com.achep.acdisplay.ui.widgets.notification.NotificationActions.java

/**
 * Sets new actions.//from w w w . j  a  v a 2  s  . com
 *
 * @param notification the host notification
 * @param actions      the actions to set
 */
public void setActions(@Nullable OpenNotification notification, @Nullable Action[] actions) {
    Check.getInstance().isInMainThread();

    mRemoteInputsMap.clear();
    mActionsMap.clear();
    hideRii();

    if (actions == null) {
        // Free actions' container.
        removeAllViews();
        return;
    } else {
        assert notification != null;
    }

    int count = actions.length;
    View[] views = new View[count];

    // Find available views.
    int childCount = getChildCount();
    int a = Math.min(childCount, count);
    for (int i = 0; i < a; i++) {
        views[i] = getChildAt(i);
    }

    // Remove redundant views.
    for (int i = childCount - 1; i >= count; i--) {
        removeViewAt(i);
    }

    LayoutInflater inflater = null;
    for (int i = 0; i < count; i++) {
        final Action action = actions[i];
        View root = views[i];

        if (root == null) {
            // Initialize layout inflater only when we really need it.
            if (inflater == null) {
                inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                assert inflater != null;
            }

            root = inflater.inflate(getActionLayoutResource(), this, false);
            root = onCreateActionView(root);
            // We need to keep all IDs unique to make
            // TransitionManager.beginDelayedTransition(viewGroup, null)
            // work correctly!
            root.setId(getChildCount() + 1);
            addView(root);
        }

        mActionsMap.put(root, action);

        int style = Typeface.NORMAL;
        root.setOnLongClickListener(null);
        if (action.intent != null) {
            root.setEnabled(true);
            root.setOnClickListener(mActionsOnClick);

            RemoteInput remoteInput = getRemoteInput(action);
            if (remoteInput != null) {
                mRemoteInputsMap.put(action, remoteInput);
                root.setOnLongClickListener(mActionsOnLongClick);

                // Highlight the action
                style = Typeface.ITALIC;
            }
        } else {
            root.setEnabled(false);
            root.setOnClickListener(null);
        }

        // Get message view and apply the content.
        TextView textView = root instanceof TextView ? (TextView) root
                : (TextView) root.findViewById(android.R.id.title);
        textView.setText(action.title);
        if (mTypeface == null)
            mTypeface = textView.getTypeface();
        textView.setTypeface(mTypeface, style);

        Drawable icon = NotificationUtils.getDrawable(getContext(), notification, action.icon);
        if (icon != null)
            icon = onCreateActionIcon(icon);

        if (Device.hasJellyBeanMR1Api()) {
            textView.setCompoundDrawablesRelative(icon, null, null, null);
        } else {
            textView.setCompoundDrawables(icon, null, null, null);
        }
    }
}

From source file:com.example.jingzhongjie.tabbarviewtest.widget.PagerSlidingTabStrip.java

private void updateTabStyles() {
    for (int i = 0; i < tabCount; i++) {
        View v = tabsContainer.getChildAt(i);
        v.setBackgroundResource(tabBackgroundResId);
        if (v instanceof TextView) {
            TextView tab = (TextView) v;
            tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
            tab.setTypeface(tabTypeface, Typeface.NORMAL);
            tab.setTextColor(defaultTextColor);
            // setAllCaps() is only available from API 14, so the upper case is made manually if we are on a
            // pre-ICS-build
            if (textAllCaps) {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                    tab.setAllCaps(true);
                } else {
                    tab.setText(tab.getText().toString().toUpperCase(locale));
                }/*from ww w.  jav a2 s .c  om*/
            }
        }
    }
}

From source file:es.ugr.swad.swadroid.modules.groups.EnrollmentExpandableListAdapter.java

@Override
public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView,
        ViewGroup parent) {//from  w  w  w  .  j  a v a  2s.  c  om
    ChildHolder holder;
    if (convertView == null) {
        convertView = mInflater.inflate(layoutChild, parent, false);
        holder = new ChildHolder();
        holder.linearLayout = (LinearLayout) convertView.findViewById(R.id.groupsLayout);
        holder.imagePadlock = (ImageView) convertView.findViewById(R.id.padlockIcon);
        holder.checkBox = (CheckBox) convertView.findViewById(R.id.checkBox);
        holder.checkBox.setOnClickListener(checkListener);
        holder.radioButton = (RadioButton) convertView.findViewById(R.id.radioButton);
        holder.vacantsText = (TextView) convertView.findViewById(R.id.vacantsText);
        holder.nStudentText = (TextView) convertView.findViewById(R.id.nStudentText);
        holder.maxStudentText = (TextView) convertView.findViewById(R.id.maxStudentText);
        convertView.setTag(holder);
    } else {
        holder = (ChildHolder) convertView.getTag();
    }

    Long groupTypeCode = groups.get(groupPosition).getId();
    int multiple = ((GroupType) groups.get(groupPosition)).getMultiple();

    ArrayList<Group> children = this.children.get(groupTypeCode);
    Group group = children.get(childPosition);

    boolean isCurrentMember = realMembership.get(groupTypeCode)[childPosition];
    if (isCurrentMember) {
        holder.linearLayout.setBackgroundColor(context.getResources().getColor(R.color.lightskyblue));
    } else {
        holder.linearLayout.setBackgroundColor(context.getResources().getColor(android.R.color.white));
    }

    //Data from Group
    String groupName = group.getGroupName();
    int maxStudents = group.getMaxStudents();
    int students = group.getCurrentStudents();
    int open = group.getOpen();
    int member = group.getMember();

    // Para porde hacer click en el checkbox
    Group g = (Group) getChild(groupPosition, childPosition);
    holder.checkBox.setTag(g);

    boolean freeSpot = false;
    if (maxStudents != -1) {
        if (group.getCurrentStudents() < maxStudents)
            freeSpot = true;
    } else { //if maxStudent == -1, there is not limit of students in this groups
        freeSpot = true;
    }

    if (open != 0) {
        holder.imagePadlock.setImageResource(R.drawable.padlock_green);
    } else {
        holder.imagePadlock.setImageResource(R.drawable.padlock_red);
    }

    if ((open != 0 && freeSpot) || role == Constants.TEACHER_TYPE_CODE) { //Teachers can enroll even on closed groups
        holder.checkBox.setEnabled(true);
        holder.checkBox.setTextColor(context.getResources().getColor(android.R.color.black));
        holder.imagePadlock.setEnabled(true);
        holder.nStudentText.setEnabled(true);
        holder.nStudentText.setTextColor(context.getResources().getColor(R.color.sgilight_gray_32));
        holder.maxStudentText.setEnabled(true);
        holder.maxStudentText.setTextColor(context.getResources().getColor(R.color.sgilight_gray_32));
        holder.radioButton.setEnabled(true);
        holder.radioButton.setTextColor(context.getResources().getColor(android.R.color.black));
        holder.linearLayout.setEnabled(true);
        holder.vacantsText.setEnabled(true);
        holder.vacantsText.setTextColor(context.getResources().getColor(R.color.sgilight_gray_32));
    } else {
        holder.checkBox.setEnabled(false);
        holder.checkBox.setTextColor(context.getResources().getColor(R.color.sgilight_gray));
        holder.imagePadlock.setEnabled(false);
        holder.nStudentText.setEnabled(false);
        holder.nStudentText.setTextColor(context.getResources().getColor(R.color.sgilight_gray));
        holder.maxStudentText.setEnabled(false);
        holder.maxStudentText.setTextColor(context.getResources().getColor(R.color.sgilight_gray));
        holder.radioButton.setEnabled(false);
        holder.radioButton.setTextColor(context.getResources().getColor(R.color.sgilight_gray));
        holder.linearLayout.setEnabled(false);
        holder.vacantsText.setEnabled(false);
        holder.vacantsText.setTextColor(context.getResources().getColor(R.color.sgilight_gray));
    }
    //for multiple inscriptions the groups should be checkboxes to allow multiple choice
    //otherwise the groups should be radio button to allow just a single choice
    //Teachers can enroll in multiple groups even if the enrollment type for the group type is single
    if (multiple == 0 && role != Constants.TEACHER_TYPE_CODE) { //single inscriptions:
        holder.checkBox.setVisibility(View.GONE);
        holder.radioButton.setVisibility(View.VISIBLE);

        holder.radioButton.setText(groupName);
        if (member != 0) {
            holder.radioButton.setChecked(true);
        } else {
            holder.radioButton.setChecked(false);
        }
    } else { //multiple inscriptions :

        holder.checkBox.setVisibility(View.VISIBLE);
        holder.radioButton.setVisibility(View.GONE);

        holder.checkBox.setText(groupName);
        if (member != 0) {
            holder.checkBox.setChecked(true);
        } else {
            holder.checkBox.setChecked(false);
        }
    }

    holder.nStudentText.setText(context.getString(R.string.numStudent) + ": " + String.valueOf(students));

    if (maxStudents != -1) {
        int vacants = maxStudents - students;
        holder.maxStudentText
                .setText(context.getString(R.string.maxStudent) + ": " + String.valueOf(maxStudents));
        holder.vacantsText.setText(context.getString(R.string.vacants) + ": " + String.valueOf(vacants));
        if (vacants == 0) {
            holder.vacantsText.setTextColor(context.getResources().getColor(R.color.sgi_salmon));
            holder.vacantsText.setTypeface(null, Typeface.BOLD);
        } else
            holder.vacantsText.setTypeface(null, Typeface.NORMAL);

    } else {
        holder.maxStudentText.setVisibility(View.GONE);
        holder.vacantsText
                .setText(context.getString(R.string.vacants) + ": " + context.getString(R.string.withoutLimit));
        holder.vacantsText.setTypeface(null, Typeface.NORMAL);
    }

    return convertView;
}

From source file:com.openerp.addons.messages.Message.java

public void setupListView(List<OEListViewRows> message_list) {
    // Destroying pre-loaded instance and going to create new one
    lstview = null;/*from   ww w .  j  av a  2s . c  o m*/

    // Fetching required messages for listview by filtering of requrement
    if (list != null && list.size() <= 0) {
        list = message_list;// getMessages(message_list);
    } else {
        rootView.findViewById(R.id.messageSyncWaiter).setVisibility(View.GONE);
        rootView.findViewById(R.id.txvMessageAllReadMessage).setVisibility(View.GONE);
    }

    // Handling List View controls and keys
    String[] from = new String[] { "subject|type", "body", "starred", "author_id|email_from", "date",
            "model|type" };
    int[] to = new int[] { R.id.txvMessageSubject, R.id.txvMessageBody, R.id.imgMessageStarred,
            R.id.txvMessageFrom, R.id.txvMessageDate, R.id.txvMessageTag };

    // Creating instance for listAdapter
    listAdapter = new OEListViewAdapter(scope.context(), R.layout.message_listview_items, list, from, to, db,
            true, new int[] { R.drawable.message_listview_bg_toread_selector,
                    R.drawable.message_listview_bg_tonotread_selector },
            "to_read");
    // Telling adapter to clean HTML text for key value
    listAdapter.cleanHtmlToTextOn("body");
    listAdapter.cleanDate("date", scope.User().getTimezone());
    // Setting callback handler for boolean field value change.
    listAdapter.setBooleanEventOperation("starred", R.drawable.ic_action_starred,
            R.drawable.ic_action_unstarred, updateStarred);
    listAdapter.addViewListener(new OEListViewOnCreateListener() {

        @Override
        public View listViewOnCreateListener(int position, View row_view, OEListViewRows row_data) {
            String model_name = row_data.getRow_data().get("model").toString();
            String model = model_name;
            String res_id = row_data.getRow_data().get("res_id").toString();
            if (model_name.equals("false")) {
                model_name = capitalizeString(row_data.getRow_data().get("type").toString());
            } else {
                String[] model_parts = TextUtils.split(model_name, "\\.");
                HashSet unique_parts = new HashSet(Arrays.asList(model_parts));
                model_name = capitalizeString(TextUtils.join(" ", unique_parts.toArray()));

            }
            TextView msgTag = (TextView) row_view.findViewById(R.id.txvMessageTag);
            int tag_color = 0;
            if (message_model_colors.containsKey(model_name)) {
                tag_color = message_model_colors.get(model_name);
            } else {
                tag_color = Color.parseColor(tag_colors[tag_color_count]);
                message_model_colors.put(model_name, tag_color);
                tag_color_count++;
                if (tag_color_count > tag_colors.length) {
                    tag_color_count = 0;
                }
            }
            if (model.equals("mail.group")) {
                if (UserGroups.group_names.containsKey("group_" + res_id)) {
                    model_name = UserGroups.group_names.get("group_" + res_id);
                    tag_color = UserGroups.menu_color.get("group_" + res_id);
                }
            }
            msgTag.setBackgroundColor(tag_color);
            msgTag.setText(model_name);
            TextView txvSubject = (TextView) row_view.findViewById(R.id.txvMessageSubject);
            TextView txvAuthor = (TextView) row_view.findViewById(R.id.txvMessageFrom);
            if (row_data.getRow_data().get("to_read").toString().equals("false")) {
                txvSubject.setTypeface(null, Typeface.NORMAL);
                txvSubject.setTextColor(Color.BLACK);

                txvAuthor.setTypeface(null, Typeface.NORMAL);
                txvAuthor.setTextColor(Color.BLACK);
            } else {
                txvSubject.setTypeface(null, Typeface.BOLD);
                txvSubject.setTextColor(Color.parseColor("#414141"));
                txvAuthor.setTypeface(null, Typeface.BOLD);
                txvAuthor.setTextColor(Color.parseColor("#414141"));
            }

            return row_view;
        }
    });

    // Creating instance for listview control
    lstview = (ListView) rootView.findViewById(R.id.lstMessages);
    // Providing adapter to listview
    scope.context().runOnUiThread(new Runnable() {

        @Override
        public void run() {
            lstview.setAdapter(listAdapter);

        }
    });

    // Setting listview choice mode to multiple model
    lstview.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);

    // Seeting item long click listern to activate action mode.
    lstview.setOnItemLongClickListener(new OnItemLongClickListener() {

        @Override
        public boolean onItemLongClick(AdapterView<?> arg0, View view, int index, long arg3) {
            // TODO Auto-generated method stub

            OEListViewRows data = (OEListViewRows) lstview.getAdapter().getItem(index);

            Toast.makeText(scope.context(), data.getRow_id() + " id clicked", Toast.LENGTH_LONG).show();
            view.setSelected(true);
            if (mActionMode != null) {
                return false;
            }
            // Start the CAB using the ActionMode.Callback defined above
            mActionMode = scope.context().startActionMode(mActionModeCallback);
            selectedCounter++;
            view.setBackgroundResource(R.drawable.listitem_pressed);
            // lstview.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
            return true;

        }
    });

    // Setting multi choice selection listener
    lstview.setMultiChoiceModeListener(new MultiChoiceModeListener() {
        HashMap<Integer, Boolean> selectedList = new HashMap<Integer, Boolean>();

        @Override
        public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) {
            // Here you can do something when items are
            // selected/de-selected,
            // such as update the title in the CAB
            selectedList.put(position, checked);
            if (checked) {
                selectedCounter++;
            } else {
                selectedCounter--;
            }
            if (selectedCounter != 0) {
                mode.setTitle(selectedCounter + "");
            }

        }

        @Override
        public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
            // Respond to clicks on the actions in the CAB
            HashMap<Integer, Integer> msg_pos = new HashMap<Integer, Integer>();
            OEDialog dialog = null;
            switch (item.getItemId()) {
            case R.id.menu_message_mark_unread_selected:
                Log.e("menu_message_context", "Mark as Unread");
                for (int pos : selectedList.keySet()) {
                    msg_pos.put(list.get(pos).getRow_id(), pos);
                }
                readunreadoperation = new PerformReadUnreadArchiveOperation(msg_pos, false);
                readunreadoperation.execute((Void) null);
                mode.finish();
                return true;
            case R.id.menu_message_mark_read_selected:
                Log.e("menu_message_context", "Mark as Read");
                for (int pos : selectedList.keySet()) {
                    msg_pos.put(list.get(pos).getRow_id(), pos);
                }
                readunreadoperation = new PerformReadUnreadArchiveOperation(msg_pos, true);
                readunreadoperation.execute((Void) null);
                mode.finish();
                return true;
            case R.id.menu_message_more_move_to_archive_selected:
                Log.e("menu_message_context", "Archive");
                for (int pos : selectedList.keySet()) {
                    msg_pos.put(list.get(pos).getRow_id(), pos);
                }
                readunreadoperation = new PerformReadUnreadArchiveOperation(msg_pos, false);
                readunreadoperation.execute((Void) null);
                mode.finish();
                return true;
            case R.id.menu_message_more_add_star_selected:
                for (int pos : selectedList.keySet()) {
                    msg_pos.put(list.get(pos).getRow_id(), pos);
                }

                markasTodoTask = new PerformOperation(msg_pos, true);
                markasTodoTask.execute((Void) null);

                mode.finish();

                return true;
            case R.id.menu_message_more_remove_star_selected:
                for (int pos : selectedList.keySet()) {
                    msg_pos.put(list.get(pos).getRow_id(), pos);
                }

                markasTodoTask = new PerformOperation(msg_pos, false);
                markasTodoTask.execute((Void) null);
                mode.finish();
                return true;
            default:
                return false;
            }
        }

        @Override
        public boolean onCreateActionMode(ActionMode mode, Menu menu) {
            // Inflate the menu for the CAB
            MenuInflater inflater = mode.getMenuInflater();
            inflater.inflate(R.menu.menu_fragment_message_context, menu);
            return true;
        }

        @Override
        public void onDestroyActionMode(ActionMode mode) {
            // Here you can make any necessary updates to the activity when
            // the CAB is removed. By default, selected items are
            // deselected/unchecked.

            /*
             * Perform Operation on Selected Ids.
             * 
             * row_ids are list of selected message Ids.
             */

            selectedList.clear();
            selectedCounter = 0;
            lstview.clearChoices();

        }

        @Override
        public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
            // Here you can perform updates to the CAB due to
            // an invalidate() request
            return false;
        }
    });
    lstview.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> arg0, View view, int index, long id) {
            // TODO Auto-generated method stub
            MessageDetail messageDetail = new MessageDetail();
            Bundle bundle = new Bundle();
            bundle.putInt("message_id", list.get(index).getRow_id());
            bundle.putInt("position", index);
            messageDetail.setArguments(bundle);
            scope.context().fragmentHandler.setBackStack(true, null);
            scope.context().fragmentHandler.replaceFragmnet(messageDetail);
            if (!type.equals("archive")) {
                list.remove(index);
            }
            listAdapter.refresh(list);
        }
    });

    // Getting Pull To Refresh Attacher from Main Activity
    mPullToRefreshAttacher = scope.context().getPullToRefreshAttacher();

    // Set the Refreshable View to be the ListView and the refresh listener
    // to be this.
    if (mPullToRefreshAttacher != null & lstview != null) {
        mPullToRefreshAttacher.setRefreshableView(lstview, this);
    }
}

From source file:org.rm3l.ddwrt.tiles.status.router.StatusRouterStateTile.java

/**
 * Called when a previously created loader has finished its load.  Note
 * that normally an application is <em>not</em> allowed to commit fragment
 * transactions while in this call, since it can happen after an
 * activity's state is saved.  See {@link android.support.v4.app.FragmentManager#beginTransaction()
 * FragmentManager.openTransaction()} for further discussion on this.
 * <p/>/*from  w  w w. j a v a  2 s  . co  m*/
 * <p>This function is guaranteed to be called prior to the release of
 * the last data that was supplied for this Loader.  At this point
 * you should remove all use of the old data (since it will be released
 * soon), but should not do your own release of the data since its Loader
 * owns it and will take care of that.  The Loader will take care of
 * management of its data so you don't have to.  In particular:
 * <p/>
 * <ul>
 * <li> <p>The Loader will monitor for changes to the data, and report
 * them to you through new calls here.  You should not monitor the
 * data yourself.  For example, if the data is a {@link android.database.Cursor}
 * and you place it in a {@link android.widget.CursorAdapter}, use
 * the {@link android.widget.CursorAdapter#CursorAdapter(android.content.Context,
 * android.database.Cursor, int)} constructor <em>without</em> passing
 * in either {@link android.widget.CursorAdapter#FLAG_AUTO_REQUERY}
 * or {@link android.widget.CursorAdapter#FLAG_REGISTER_CONTENT_OBSERVER}
 * (that is, use 0 for the flags argument).  This prevents the CursorAdapter
 * from doing its own observing of the Cursor, which is not needed since
 * when a change happens you will get a new Cursor throw another call
 * here.
 * <li> The Loader will release the data once it knows the application
 * is no longer using it.  For example, if the data is
 * a {@link android.database.Cursor} from a {@link android.content.CursorLoader},
 * you should not call close() on it yourself.  If the Cursor is being placed in a
 * {@link android.widget.CursorAdapter}, you should use the
 * {@link android.widget.CursorAdapter#swapCursor(android.database.Cursor)}
 * method so that the old Cursor is not closed.
 * </ul>
 *
 * @param loader The Loader that has finished.
 * @param data   The data generated by the Loader.
 */
@Override
public void onLoadFinished(@NotNull final Loader<NVRAMInfo> loader, @Nullable NVRAMInfo data) {
    //Set tiles
    Log.d(LOG_TAG, "onLoadFinished: loader=" + loader + " / data=" + data);

    layout.findViewById(R.id.tile_status_router_router_state_loading_view).setVisibility(View.GONE);
    layout.findViewById(R.id.tile_status_router_router_state_header_loading_view).setVisibility(View.GONE);
    layout.findViewById(R.id.tile_status_router_router_state_gridLayout).setVisibility(View.VISIBLE);
    layout.findViewById(R.id.tile_status_router_router_state_header_layout).setVisibility(View.VISIBLE);

    if (data == null) {
        data = new NVRAMInfo().setException(new DDWRTNoDataException("No Data!"));
    }

    @NotNull
    final TextView errorPlaceHolderView = (TextView) this.layout
            .findViewById(R.id.tile_status_router_router_state_error);

    @Nullable
    final Exception exception = data.getException();

    if (!(exception instanceof DDWRTTileAutoRefreshNotAllowedException)) {

        if (exception == null) {
            errorPlaceHolderView.setVisibility(View.GONE);
        }

        //Router Name
        @NotNull
        final TextView routerNameView = (TextView) this.layout
                .findViewById(R.id.tile_status_router_router_state_title);
        final String routerName = data.getProperty(NVRAMInfo.ROUTER_NAME);
        final boolean routerNameNull = (routerName == null);
        String routerNameToSet = routerName;
        if (routerNameNull) {
            routerNameToSet = "(empty)";
        }
        routerNameView.setTypeface(null, routerNameNull ? Typeface.ITALIC : Typeface.NORMAL);

        routerNameView.setText(routerNameToSet);

        //We can change the action bar title
        //        this.layout.getSupportActionBar().setTitle((String) data);

        //WAN IP
        @NotNull
        final TextView wanIpView = (TextView) this.layout
                .findViewById(R.id.tile_status_router_router_state_wan_ip);
        wanIpView.setText(data.getProperty(NVRAMInfo.WAN_IPADDR));

        @NotNull
        final TextView routerModelView = (TextView) this.layout
                .findViewById(R.id.tile_status_router_router_state_model);
        routerModelView.setText(data.getProperty(NVRAMInfo.MODEL, "-"));

        @NotNull
        final TextView lanIpView = (TextView) this.layout
                .findViewById(R.id.tile_status_router_router_state_lan_ip);
        lanIpView.setText(data.getProperty(NVRAMInfo.LAN_IPADDR, "-"));

        @NotNull
        final TextView fwView = (TextView) this.layout
                .findViewById(R.id.tile_status_router_router_state_firmware);
        fwView.setText(data.getProperty(NVRAMInfo.FIRMWARE, "-"));

        @NotNull
        final TextView kernelView = (TextView) this.layout
                .findViewById(R.id.tile_status_router_router_state_kernel);
        kernelView.setText(data.getProperty(NVRAMInfo.KERNEL, "-"));

        @NotNull
        final TextView uptimeView = (TextView) this.layout
                .findViewById(R.id.tile_status_router_router_state_uptime);
        uptimeView.setText(data.getProperty(NVRAMInfo.UPTIME, "-"));

    }

    if (exception != null && !(exception instanceof DDWRTTileAutoRefreshNotAllowedException)) {
        //noinspection ThrowableResultOfMethodCallIgnored
        final Throwable rootCause = Throwables.getRootCause(exception);
        errorPlaceHolderView.setText("Error: " + (rootCause != null ? rootCause.getMessage() : "null"));
        final Context parentContext = this.mParentFragmentActivity;
        errorPlaceHolderView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(final View v) {
                //noinspection ThrowableResultOfMethodCallIgnored
                if (rootCause != null) {
                    Toast.makeText(parentContext, rootCause.getMessage(), Toast.LENGTH_LONG).show();
                }
            }
        });
        errorPlaceHolderView.setVisibility(View.VISIBLE);
    }

    doneWithLoaderInstance(this, loader, R.id.tile_status_router_router_state_togglebutton_title,
            R.id.tile_status_router_router_state_togglebutton_separator);

    Log.d(LOG_TAG, "onLoadFinished(): done loading!");

}