Example usage for android.widget LinearLayout setOnClickListener

List of usage examples for android.widget LinearLayout setOnClickListener

Introduction

In this page you can find the example usage for android.widget LinearLayout setOnClickListener.

Prototype

public void setOnClickListener(@Nullable OnClickListener l) 

Source Link

Document

Register a callback to be invoked when this view is clicked.

Usage

From source file:hu.fnf.devel.atlas.Atlas.java

private void addChilds(View parent, LinearLayout pll) {
    Uri.Builder builder = new Builder();
    builder.scheme("content");
    builder.authority(AtlasData.DB_AUTHORITY);
    builder.appendPath(AtlasData.TABLE_CATEGORIES);
    builder.appendPath("childs");
    builder.appendPath(String.valueOf(parent.getId()));

    Cursor items = getContentResolver().query(builder.build(), AtlasData.CATEGORIES_COLUMNS, null, null, null);

    if (items != null && items.moveToFirst()) {
        LinearLayout ll = null;
        do {//w  w w.  ja  va  2  s  .  com
            ll = new LinearLayout(getApplicationContext());
            LayoutParams llp = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
            ll.setLayoutParams(llp);
            TextView child = new TextView(getApplicationContext());
            child.setTextAppearance(getApplicationContext(), android.R.style.TextAppearance_Medium_Inverse);

            ll.setId(items.getInt(AtlasData.CATEGORIES_ID));
            child.setId(items.getInt(AtlasData.CATEGORIES_ID));
            child.setText(items.getString(AtlasData.CATEGORIES_NAME));
            for (int i = 0; i < AtlasData.MAX_CAT_DEPTH - items.getInt(AtlasData.CATEGORIES_DEPTH); i++) {
                TextView holder = new TextView(getApplicationContext());
                holder.setText("        ");
                ll.addView(holder);
            }

            child.setClickable(true);

            Log.d("Atlas", "build to ll: " + child.getText().toString());
            ll.addView(child);

            ll.setOnClickListener(onCatClick);
            child.setOnClickListener(onCatClick);

            View line = new View(getApplicationContext());

            line.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, 1));
            line.setBackgroundColor(Color.GRAY);

            pll.addView(line);
            pll.addView(ll);
            Log.d("Atlas", "build to pll: " + ll.getId());

            addChilds(child, pll);
        } while (items.moveToNext());
        items.close();
    } else {
        // no more kids
        return;
    }
}

From source file:com.lloydtorres.stately.nation.OverviewSubFragment.java

/**
 * Sets up colours, etc. for the WA voting indicators, which are identical in all but name.
 * @param holder/*  ww  w .  j a  va2s.  co  m*/
 * @param content
 * @param vote
 * @param councilId
 */
private void setAssemblyVoteState(LinearLayout holder, TextView content, String vote, int councilId) {
    // Intent to open the ResolutionActivity
    Intent resolutionActivityLaunch = new Intent(getContext(), ResolutionActivity.class);
    resolutionActivityLaunch.putExtra(ResolutionActivity.TARGET_COUNCIL_ID, councilId);
    final Intent fResolution = resolutionActivityLaunch;

    // Colour of the indicator as well as the assembly name
    int stateColour;
    String assemblyName;

    holder.setVisibility(View.VISIBLE);

    switch (councilId) {
    case Assembly.GENERAL_ASSEMBLY:
        assemblyName = getString(R.string.wa_general_assembly);
        break;
    case Assembly.SECURITY_COUNCIL:
        assemblyName = getString(R.string.wa_security_council);
        break;
    default:
        assemblyName = "";
        break;
    }

    // If voting FOR the resolution
    if (getString(R.string.wa_vote_state_for).equals(vote)) {
        stateColour = SparkleHelper.waColours[0];
        content.setText(String.format(getString(R.string.card_overview_wa_vote), assemblyName, vote));
    }
    // If voting AGAINST the resolution
    else if (getString(R.string.wa_vote_state_against).equals(vote)) {
        stateColour = SparkleHelper.waColours[1];
        content.setText(String.format(getString(R.string.card_overview_wa_vote), assemblyName, vote));
    }
    // If no vote yet
    else {
        stateColour = SparkleHelper.waColours[2];
        content.setText(String.format(getString(R.string.card_overview_wa_novote), assemblyName));
    }

    holder.setBackgroundColor(ContextCompat.getColor(getContext(), stateColour));
    holder.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            startActivity(fResolution);
        }
    });
}

From source file:com.roamprocess1.roaming4world.ui.messages.MessageActivity.java

public void setActionBar() {
    try {/*from   w  w w .j  a v  a  2  s .c  o m*/
        com.actionbarsherlock.app.ActionBar actionBar = getSupportActionBar();
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setHomeButtonEnabled(true);
        actionBar.setDisplayShowHomeEnabled(false);
        actionBar.setDisplayShowTitleEnabled(false);
        actionBar.setCustomView(R.layout.chatactionbar);
        actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);

        pic = (ImageView) actionBar.getCustomView().findViewById(R.id.ab_userpic);
        name = (TextView) actionBar.getCustomView().findViewById(R.id.ab_userName);
        LinearLayout backfrChat = (LinearLayout) actionBar.getCustomView().findViewById(R.id.ll_backFromChat);
        tv_userStatus = (TextView) actionBar.getCustomView().findViewById(R.id.ab_userStatus);
        LinearLayout ll_userprofile = (LinearLayout) actionBar.getCustomView()
                .findViewById(R.id.ll_calluserProfile);

        btn_filetransfer = (Button) actionBar.getCustomView().findViewById(R.id.btnattechment);

        btn_filetransfer.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                viewAttechmentPopup(v);

            }
        });

        backfrChat.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                callBack();
            }
        });

        ll_userprofile.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                callUserProfileActivity();
            }
        });

        vv = detailFragment.getView();
        bodyInput = (EditText) vv.findViewById(R.id.embedded_text_editor);
        Fl_Emoticon_Holder = (FrameLayout) vv.findViewById(R.id.fl_emojicons);
        btn_emoticon_show = (ImageButton) vv.findViewById(R.id.ib_enable_emoticon_frame);

        String user_number = prefs.getString(stored_chatuserNumber, "No Value");
        if (user_number.contains("@")) {
            String[] nu = user_number.split("@");
            nu = nu[0].split(":");
            user_number = nu[1];
        }

        supportnum = prefs.getString(stored_supportnumber, "");
        String nu = detailFragment.stripNumber(user_number);
        String fileuri = Environment.getExternalStorageDirectory() + "/R4W/ProfilePic/" + nu + ".png";
        Log.d("fileuri", fileuri + " !");
        Log.d("supportnum", supportnum);
        Log.d("nu", nu);

        if (nu.equals(supportnum)) {
            pic.setImageResource(R.drawable.roaminglogo);
        } else {
            File imageDirectoryprofile = new File(fileuri);
            if (imageDirectoryprofile.exists()) {
                pic.setImageURI(Uri.parse(fileuri));
            } else {
                pic.setImageResource(R.drawable.ic_contact_picture_180_holo_light);
            }
        }

        String username = nu;

        if (dbContacts == null) {
            dbContacts = new DBContacts(MessageActivity.this);
        }
        String nameServer = "", nameContact = "";
        dbContacts.openToRead();
        Cursor cursor = dbContacts.fetch_contact_from_R4W(nu);
        if (cursor.getCount() > 0) {
            cursor.moveToFirst();
            nameServer = cursor.getString(5).toString();
            nameContact = cursor.getString(2).toString();
            cursor.close();
            dbContacts.close();

            Log.d("nameServer", nameServer + " in");
            Log.d("nameContact", nameContact + " in");

            if (!nameServer.equals("***no name***")) {
                username = nameServer;
            } else {
                username = nameContact;
            }
            name.setText(username);
        } else {
            name.setText(nu);
        }

    } catch (Exception e) {
        // TODO: handle exception
    }
}

From source file:com.abroad.ruianju.im.ui.SettingsFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    if (savedInstanceState != null && savedInstanceState.getBoolean("isConflict", false))
        return;// w w  w.j  a v  a 2 s.  c  o  m
    rl_switch_notification = (RelativeLayout) getView().findViewById(R.id.rl_switch_notification);
    rl_switch_sound = (RelativeLayout) getView().findViewById(R.id.rl_switch_sound);
    rl_switch_vibrate = (RelativeLayout) getView().findViewById(R.id.rl_switch_vibrate);
    rl_switch_speaker = (RelativeLayout) getView().findViewById(R.id.rl_switch_speaker);
    rl_switch_chatroom_leave = (RelativeLayout) getView().findViewById(R.id.rl_switch_chatroom_owner_leave);
    rl_switch_delete_msg_when_exit_group = (RelativeLayout) getView()
            .findViewById(R.id.rl_switch_delete_msg_when_exit_group);
    rl_switch_auto_accept_group_invitation = (RelativeLayout) getView()
            .findViewById(R.id.rl_switch_auto_accept_group_invitation);
    rl_switch_adaptive_video_encode = (RelativeLayout) getView()
            .findViewById(R.id.rl_switch_adaptive_video_encode);
    rl_custom_server = (RelativeLayout) getView().findViewById(R.id.rl_custom_server);

    notifiSwitch = (EaseSwitchButton) getView().findViewById(R.id.switch_notification);
    soundSwitch = (EaseSwitchButton) getView().findViewById(R.id.switch_sound);
    vibrateSwitch = (EaseSwitchButton) getView().findViewById(R.id.switch_vibrate);
    speakerSwitch = (EaseSwitchButton) getView().findViewById(R.id.switch_speaker);
    ownerLeaveSwitch = (EaseSwitchButton) getView().findViewById(R.id.switch_owner_leave);
    switch_delete_msg_when_exit_group = (EaseSwitchButton) getView()
            .findViewById(R.id.switch_delete_msg_when_exit_group);
    switch_auto_accept_group_invitation = (EaseSwitchButton) getView()
            .findViewById(R.id.switch_auto_accept_group_invitation);
    switch_adaptive_video_encode = (EaseSwitchButton) getView().findViewById(R.id.switch_adaptive_video_encode);
    LinearLayout llChange = (LinearLayout) getView().findViewById(R.id.ll_change);
    logoutBtn = (Button) getView().findViewById(R.id.btn_logout);
    if (!TextUtils.isEmpty(EMClient.getInstance().getCurrentUser())) {
        logoutBtn.setText(
                getString(R.string.button_logout) + "(" + EMClient.getInstance().getCurrentUser() + ")");
    }
    customServerSwitch = (EaseSwitchButton) getView().findViewById(R.id.switch_custom_server);

    textview1 = (TextView) getView().findViewById(R.id.textview1);
    textview2 = (TextView) getView().findViewById(R.id.textview2);

    blacklistContainer = (LinearLayout) getView().findViewById(R.id.ll_black_list);
    userProfileContainer = (LinearLayout) getView().findViewById(R.id.ll_user_profile);
    llDiagnose = (LinearLayout) getView().findViewById(R.id.ll_diagnose);
    pushNick = (LinearLayout) getView().findViewById(R.id.ll_set_push_nick);

    settingsModel = DemoHelper.getInstance().getModel();
    chatOptions = EMClient.getInstance().getOptions();

    blacklistContainer.setOnClickListener(this);
    userProfileContainer.setOnClickListener(this);
    rl_switch_notification.setOnClickListener(this);
    rl_switch_sound.setOnClickListener(this);
    rl_switch_vibrate.setOnClickListener(this);
    rl_switch_speaker.setOnClickListener(this);
    customServerSwitch.setOnClickListener(this);
    rl_custom_server.setOnClickListener(this);
    logoutBtn.setOnClickListener(this);
    llDiagnose.setOnClickListener(this);
    pushNick.setOnClickListener(this);
    rl_switch_chatroom_leave.setOnClickListener(this);
    rl_switch_delete_msg_when_exit_group.setOnClickListener(this);
    rl_switch_auto_accept_group_invitation.setOnClickListener(this);
    rl_switch_adaptive_video_encode.setOnClickListener(this);
    llChange.setOnClickListener(this);

    // the vibrate and sound notification are allowed or not?
    if (settingsModel.getSettingMsgNotification()) {
        notifiSwitch.openSwitch();
    } else {
        notifiSwitch.closeSwitch();
    }

    // sound notification is switched on or not?
    if (settingsModel.getSettingMsgSound()) {
        soundSwitch.openSwitch();
    } else {
        soundSwitch.closeSwitch();
    }

    // vibrate notification is switched on or not?
    if (settingsModel.getSettingMsgVibrate()) {
        vibrateSwitch.openSwitch();
    } else {
        vibrateSwitch.closeSwitch();
    }

    // the speaker is switched on or not?
    if (settingsModel.getSettingMsgSpeaker()) {
        speakerSwitch.openSwitch();
    } else {
        speakerSwitch.closeSwitch();
    }

    // if allow owner leave
    if (settingsModel.isChatroomOwnerLeaveAllowed()) {
        ownerLeaveSwitch.openSwitch();
    } else {
        ownerLeaveSwitch.closeSwitch();
    }

    // delete messages when exit group?
    if (settingsModel.isDeleteMessagesAsExitGroup()) {
        switch_delete_msg_when_exit_group.openSwitch();
    } else {
        switch_delete_msg_when_exit_group.closeSwitch();
    }

    if (settingsModel.isAutoAcceptGroupInvitation()) {
        switch_auto_accept_group_invitation.openSwitch();
    } else {
        switch_auto_accept_group_invitation.closeSwitch();
    }

    if (settingsModel.isAdaptiveVideoEncode()) {
        switch_adaptive_video_encode.openSwitch();
        EMClient.getInstance().callManager().getVideoCallHelper().setAdaptiveVideoFlag(true);
    } else {
        switch_adaptive_video_encode.closeSwitch();
        EMClient.getInstance().callManager().getVideoCallHelper().setAdaptiveVideoFlag(false);
    }

    if (settingsModel.isCustomServerEnable()) {
        customServerSwitch.openSwitch();
    } else {
        customServerSwitch.closeSwitch();
    }
}

From source file:cn.ucai.superwechat.ui.SettingsFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    if (savedInstanceState != null && savedInstanceState.getBoolean("isConflict", false))
        return;//www. ja v a2  s .c  om
    rl_switch_notification = (RelativeLayout) getView().findViewById(R.id.rl_switch_notification);
    rl_switch_sound = (RelativeLayout) getView().findViewById(R.id.rl_switch_sound);
    rl_switch_vibrate = (RelativeLayout) getView().findViewById(R.id.rl_switch_vibrate);
    rl_switch_speaker = (RelativeLayout) getView().findViewById(R.id.rl_switch_speaker);
    rl_switch_chatroom_leave = (RelativeLayout) getView().findViewById(R.id.rl_switch_chatroom_owner_leave);
    rl_switch_delete_msg_when_exit_group = (RelativeLayout) getView()
            .findViewById(R.id.rl_switch_delete_msg_when_exit_group);
    rl_switch_auto_accept_group_invitation = (RelativeLayout) getView()
            .findViewById(R.id.rl_switch_auto_accept_group_invitation);
    rl_switch_adaptive_video_encode = (RelativeLayout) getView()
            .findViewById(R.id.rl_switch_adaptive_video_encode);
    rl_custom_server = (RelativeLayout) getView().findViewById(R.id.rl_custom_server);

    notifiSwitch = (EaseSwitchButton) getView().findViewById(R.id.switch_notification);
    soundSwitch = (EaseSwitchButton) getView().findViewById(R.id.switch_sound);
    vibrateSwitch = (EaseSwitchButton) getView().findViewById(R.id.switch_vibrate);
    speakerSwitch = (EaseSwitchButton) getView().findViewById(R.id.switch_speaker);
    ownerLeaveSwitch = (EaseSwitchButton) getView().findViewById(R.id.switch_owner_leave);
    switch_delete_msg_when_exit_group = (EaseSwitchButton) getView()
            .findViewById(R.id.switch_delete_msg_when_exit_group);
    switch_auto_accept_group_invitation = (EaseSwitchButton) getView()
            .findViewById(R.id.switch_auto_accept_group_invitation);
    switch_adaptive_video_encode = (EaseSwitchButton) getView().findViewById(R.id.switch_adaptive_video_encode);
    LinearLayout llChange = (LinearLayout) getView().findViewById(R.id.ll_change);
    logoutBtn = (Button) getView().findViewById(R.id.btn_logout);
    if (!TextUtils.isEmpty(EMClient.getInstance().getCurrentUser())) {
        logoutBtn.setText(
                getString(R.string.button_logout) + "(" + EMClient.getInstance().getCurrentUser() + ")");
    }
    customServerSwitch = (EaseSwitchButton) getView().findViewById(R.id.switch_custom_server);

    textview1 = (TextView) getView().findViewById(R.id.textview1);
    textview2 = (TextView) getView().findViewById(R.id.textview2);

    blacklistContainer = (LinearLayout) getView().findViewById(R.id.ll_black_list);
    userProfileContainer = (LinearLayout) getView().findViewById(R.id.ll_user_profile);
    llDiagnose = (LinearLayout) getView().findViewById(R.id.ll_diagnose);
    pushNick = (LinearLayout) getView().findViewById(R.id.ll_set_push_nick);

    settingsModel = SuperWeChatHelper.getInstance().getModel();
    chatOptions = EMClient.getInstance().getOptions();

    blacklistContainer.setOnClickListener(this);
    userProfileContainer.setOnClickListener(this);
    rl_switch_notification.setOnClickListener(this);
    rl_switch_sound.setOnClickListener(this);
    rl_switch_vibrate.setOnClickListener(this);
    rl_switch_speaker.setOnClickListener(this);
    customServerSwitch.setOnClickListener(this);
    rl_custom_server.setOnClickListener(this);
    logoutBtn.setOnClickListener(this);
    llDiagnose.setOnClickListener(this);
    pushNick.setOnClickListener(this);
    rl_switch_chatroom_leave.setOnClickListener(this);
    rl_switch_delete_msg_when_exit_group.setOnClickListener(this);
    rl_switch_auto_accept_group_invitation.setOnClickListener(this);
    rl_switch_adaptive_video_encode.setOnClickListener(this);
    llChange.setOnClickListener(this);

    // the vibrate and sound notification are allowed or not?
    if (settingsModel.getSettingMsgNotification()) {
        notifiSwitch.openSwitch();
    } else {
        notifiSwitch.closeSwitch();
    }

    // sound notification is switched on or not?
    if (settingsModel.getSettingMsgSound()) {
        soundSwitch.openSwitch();
    } else {
        soundSwitch.closeSwitch();
    }

    // vibrate notification is switched on or not?
    if (settingsModel.getSettingMsgVibrate()) {
        vibrateSwitch.openSwitch();
    } else {
        vibrateSwitch.closeSwitch();
    }

    // the speaker is switched on or not?
    if (settingsModel.getSettingMsgSpeaker()) {
        speakerSwitch.openSwitch();
    } else {
        speakerSwitch.closeSwitch();
    }

    // if allow owner leave
    if (settingsModel.isChatroomOwnerLeaveAllowed()) {
        ownerLeaveSwitch.openSwitch();
    } else {
        ownerLeaveSwitch.closeSwitch();
    }

    // delete messages when exit group?
    if (settingsModel.isDeleteMessagesAsExitGroup()) {
        switch_delete_msg_when_exit_group.openSwitch();
    } else {
        switch_delete_msg_when_exit_group.closeSwitch();
    }

    if (settingsModel.isAutoAcceptGroupInvitation()) {
        switch_auto_accept_group_invitation.openSwitch();
    } else {
        switch_auto_accept_group_invitation.closeSwitch();
    }

    if (settingsModel.isAdaptiveVideoEncode()) {
        switch_adaptive_video_encode.openSwitch();
        EMClient.getInstance().callManager().getVideoCallHelper().setAdaptiveVideoFlag(true);
    } else {
        switch_adaptive_video_encode.closeSwitch();
        EMClient.getInstance().callManager().getVideoCallHelper().setAdaptiveVideoFlag(false);
    }

    if (settingsModel.isCustomServerEnable()) {
        customServerSwitch.openSwitch();
    } else {
        customServerSwitch.closeSwitch();
    }
}

From source file:com.bofsoft.laio.laiovehiclegps.Fragment.BaiduMapFragment.java

/**
 * ////from   w w  w.  ja v a 2 s.  co m
 */
private void showLocation(final GPSInfoData gpsInfoData) {
    int i = 0;
    if (gpsInfoData == null) {
        return;
    }
    //maker?
    if (mList != null) {
        for (i = 0; i < mList.size(); i++) {
            Marker marker = mList.get(i);
            if (marker.getExtraInfo().getString("License").equalsIgnoreCase(gpsInfoData.License)) {
                marker.setToTop();
                break;
            }
        }
    }
    //        // InfoWindowview
    //        if (marker == null) {
    //            return;
    //        }
    //        for (i = 0; i < mList.size(); i++) {
    //            if (marker == mList.get(i)) {
    //                currentMarkerNum = i;
    //                break;
    //            }
    //        }

    //        latitude = carListData.InfoList.get(currentMarkerNum).Latitude;
    //        longitude = carListData.InfoList.get(currentMarkerNum).Longitude;

    //        // GPSGPS??????
    LatLng tmpLL = new LatLng(gpsInfoData.getLatitude(), gpsInfoData.getLongitude());
    // GPSGPS??????
    CoordinateConverter converter = new CoordinateConverter();
    converter.from(CoordinateConverter.CoordType.GPS);
    converter.coord(tmpLL);
    final LatLng pt = converter.convert();

    View view = LayoutInflater.from(getActivity()).inflate(R.layout.map_popwindow, null); //
    ImageView iv_close = (ImageView) view.findViewById(R.id.iv_close);
    TextView tv_CarLicense = (TextView) view.findViewById(R.id.tv_CarLicense);

    LinearLayout ll_Navigation = (LinearLayout) view.findViewById(R.id.ll_Navigation);

    LinearLayout ll_Track = (LinearLayout) view.findViewById(R.id.ll_Track);
    final ImageView iv_Track = (ImageView) view.findViewById(R.id.iv_Track);
    final TextView tv_Track = (TextView) view.findViewById(R.id.tv_Track);

    TextView tv_equipmentTime = (TextView) view.findViewById(R.id.tv_equipmentTime);
    TextView tv_status = (TextView) view.findViewById(R.id.tv_status);
    TextView tv_speed = (TextView) view.findViewById(R.id.tv_speed);
    TextView tv_latlong = (TextView) view.findViewById(R.id.tv_latlong);
    TextView tv_address = (TextView) view.findViewById(R.id.tv_address);

    iv_close.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mBaiduMap.hideInfoWindow();//??
            isPopWindowShow = false;
            iv_normal.setVisibility(View.VISIBLE);
            iv_satellite.setVisibility(View.VISIBLE);
            iv_traffic.setVisibility(View.VISIBLE);
        }
    });
    tv_CarLicense.setText(carListData.InfoList.get(currentMarkerNum).License);
    ll_Navigation.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            //
            isTrack = false;
            iv_Track.setImageResource(R.mipmap.popwindow_track_on);
            tv_Track.setText("");
            GPS_Monitor(false);
            ll_distance.setVisibility(View.GONE);
            mMarkerTemp = null;
            routeplanToNavi(BNRoutePlanNode.CoordinateType.BD09LL);
        }
    });
    if (mMarkerTemp != null && mMarkerTemp.getLicense().equalsIgnoreCase(gpsInfoData.getLicense())) {
        if (ll_distance.getVisibility() == View.VISIBLE) {
            isTrack = true;
            iv_Track.setImageResource(R.mipmap.popwindow_track_off);
            tv_Track.setText("");
        }
    } else {
        if (ll_distance.getVisibility() == View.VISIBLE) {
            GPS_Monitor(false);
            ll_distance.setVisibility(View.GONE);
            mMarkerTemp = null;
        }
    }

    ll_Track.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            //
            if (isTrack) {
                isTrack = false;
                iv_Track.setImageResource(R.mipmap.popwindow_track_on);
                tv_Track.setText("");
                GPS_Monitor(false);
                ll_distance.setVisibility(View.GONE);
                mMarkerTemp = null;
            } else {
                isTrack = true;
                iv_Track.setImageResource(R.mipmap.popwindow_track_off);
                tv_Track.setText("");
                GPS_Monitor(true);
                ll_distance.setVisibility(View.VISIBLE);
                tv_distance.setText(getDistance(curLocation, pt));
                mMarkerTemp = gpsInfoData;
            }
            showLocation(gpsInfoData);
        }
    });

    tv_equipmentTime.setText(carListData.InfoList.get(currentMarkerNum).Datetime);
    if (carListData.InfoList.get(currentMarkerNum).Status == 0) {
        tv_status.setText("");
    } else {
        tv_status.setText(carListData.InfoList.get(currentMarkerNum).StatusContent);
    }
    tv_speed.setText(carListData.InfoList.get(currentMarkerNum).Speed + "km/h");
    tv_latlong.setText(gpsInfoData.getLongitude() + "," + gpsInfoData.getLatitude() + " ?:"
            + carListData.InfoList.get(currentMarkerNum).getDirectionStr());
    hasPopAddress = true;
    //        mSearch.reverseGeoCode(new ReverseGeoCodeOption().location(pt));
    if (gpsInfoData.getAddress() == null || gpsInfoData.getAddress().length() == 0) {
        HomeFragment.LoadAddHelper loadAddHelper = new HomeFragment.LoadAddHelper(gpsInfoData);
        loadAddHelper.loadReverseGeoCode();
    }
    tv_address.setText(
            "?           " + (carListData.InfoList.get(currentMarkerNum).getAddress() == null ? ""
                    : carListData.InfoList.get(currentMarkerNum).getAddress()));

    MapStatus.Builder builder = new MapStatus.Builder();
    builder.target(pt);//.zoom(18)
    mBaiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build()));

    // InfoWindow
    mInfoWindow = new InfoWindow(view, pt, -30);
    iv_normal.setVisibility(View.GONE);
    iv_satellite.setVisibility(View.GONE);
    iv_traffic.setVisibility(View.GONE);
    mBaiduMap.showInfoWindow(mInfoWindow); //
    isPopWindowShow = true;
    mShowMarker = gpsInfoData;
}

From source file:org.linphone.InCallActivity.java

private void displayCall(Resources resources, LinphoneCall call, int index) {
    String sipUri = call.getRemoteAddress().asStringUriOnly();
    LinphoneAddress lAddress;//from  ww  w. j  a va2s.  c  o m
    try {
        lAddress = LinphoneCoreFactory.instance().createLinphoneAddress(sipUri);
    } catch (LinphoneCoreException e) {
        Log.e("Incall activity cannot parse remote address", e);
        lAddress = LinphoneCoreFactory.instance().createLinphoneAddress("uknown", "unknown", "unkonown");
    }

    // Control Row
    LinearLayout callView = (LinearLayout) inflater.inflate(R.layout.active_call_control_row, container, false);
    callView.setId(index + 1);
    setContactName(callView, lAddress, sipUri, resources);
    displayCallStatusIconAndReturnCallPaused(callView, call);
    setRowBackground(callView, index);
    registerCallDurationTimer(callView, call);
    callsList.addView(callView);

    // Image Row
    LinearLayout imageView = (LinearLayout) inflater.inflate(R.layout.active_call_image_row, container, false);
    Contact contact = ContactsManager.getInstance()
            .findContactWithAddress(imageView.getContext().getContentResolver(), lAddress);
    if (contact != null) {
        displayOrHideContactPicture(imageView, contact.getPhotoUri(), contact.getThumbnailUri(), false);
    } else {
        displayOrHideContactPicture(imageView, null, null, false);
    }
    callsList.addView(imageView);

    callView.setTag(imageView);
    callView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (v.getTag() != null) {
                View imageView = (View) v.getTag();
                if (imageView.getVisibility() == View.VISIBLE)
                    imageView.setVisibility(View.GONE);
                else
                    imageView.setVisibility(View.VISIBLE);
                callsList.invalidate();
            }
        }
    });
}

From source file:com.zertinteractive.wallpaper.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Log.e(LOG_TAG, "onCreate()");
    setContentView(R.layout.activity_main);
    context = this;
    checkPermission();//from  ww  w  .  java2  s .co m
    DetailActivity.setContext(this);
    initDownloadComponents();
    downloadTestImage();
    initSearchGridView();

    progressBar = (ProgressBar) findViewById(R.id.progressBarImageSearch);
    progressBar.setVisibility(View.GONE);

    searchQueryButton = (ImageView) findViewById(R.id.search_query_ok);
    searchQueryButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            InputMethodManager in = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
            in.hideSoftInputFromWindow(searchKey.getApplicationWindowToken(),
                    InputMethodManager.HIDE_NOT_ALWAYS);
            searchActionMethod();
        }
    });

    searchKey = (EditText) findViewById(R.id.search_key);
    searchKey.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            //                if (event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) {
            //                    InputMethodManager in = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
            //                    in.hideSoftInputFromWindow(searchKey.getApplicationWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
            //                    Log.e("SEARCH", searchKey.getText().toString());
            //                }
            searchActionMethod();
            return false;
        }
    });

    searchQueryClear = (ImageView) findViewById(R.id.search_query_clear);
    searchQueryClear.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            searchKey.setText("");
        }
    });

    // Gets the ad view defined in layout/ad_fragment.xml with ad unit ID set in
    // values/strings.xml.
    mAdView = (AdView) findViewById(R.id.adView);
    mAdView.setVisibility(View.GONE);

    //        mAdView.setScaleX(1.3f);
    AdRequest adRequest = new AdRequest.Builder().addTestDevice(AdRequest.DEVICE_ID_EMULATOR).build();

    // Start loading the ad in sthe background.
    mAdView.loadAd(adRequest);
    mAdView.setAdListener(new AdListener() {
        @Override
        public void onAdLoaded() {
            super.onAdLoaded();
            mAdView.setVisibility(View.VISIBLE);
        }
    });

    //        AdView mAdView = (AdView) findViewById(R.id.adView);
    //        AdRequest adRequest = new AdRequest.Builder().build();
    //        mAdView.loadAd(adRequest);

    initWallpaperLists();
    initRecyclerView(GRIDVIEW_COLUMN);
    initSearchView();
    initFab();
    initToolbar();
    setupDrawerLayout();
    setCategorySutter(false);
    categorySutterChange(1200);
    //        setNotification();

    setupWindowAnimations();

    reminderCount = 0;

    timerTasks = new TimerTasks(context);

    timerTasks.startTimerTask();

    currentWallpaperCategory = WallpaperCategory.ALL;
    DetailActivity.checkDir();

    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        setRecyclerAdapter(recyclerView, 0);
        currentWallpaperCategory = WallpaperCategory.ALL;
    }

    LinearLayout categoryHappyWallpaper = (LinearLayout) findViewById(R.id.category_happy);
    LinearLayout categorySadWallpaper = (LinearLayout) findViewById(R.id.category_sad);
    LinearLayout categorySurpriseWallpaper = (LinearLayout) findViewById(R.id.category_surprise);
    LinearLayout categoryAngryWallpaper = (LinearLayout) findViewById(R.id.category_angry);
    LinearLayout categoryFunnyWallpaper = (LinearLayout) findViewById(R.id.category_funny);
    LinearLayout categoryAmazedWallpaper = (LinearLayout) findViewById(R.id.category_amazed);
    categoryHappyWallpaper.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            setRecyclerAdapter(recyclerView, 1);
            currentWallpaperCategory = WallpaperCategory.HAPPY;
        }
    });
    categorySadWallpaper.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            setRecyclerAdapter(recyclerView, 2);
            currentWallpaperCategory = WallpaperCategory.SAD;
        }
    });
    categorySurpriseWallpaper.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            setRecyclerAdapter(recyclerView, 3);
            currentWallpaperCategory = WallpaperCategory.SURPRISE;
        }
    });
    categoryAngryWallpaper.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            setRecyclerAdapter(recyclerView, 4);
            currentWallpaperCategory = WallpaperCategory.ANGRY;
        }
    });
    categoryFunnyWallpaper.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            setRecyclerAdapter(recyclerView, 5);
            currentWallpaperCategory = WallpaperCategory.FUNNY;
        }
    });
    categoryAmazedWallpaper.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            setRecyclerAdapter(recyclerView, 6);
            currentWallpaperCategory = WallpaperCategory.AMAZED;
        }
    });

    ImageView category_daily = (ImageView) findViewById(R.id.category_daily);
    ImageView category_featured = (ImageView) findViewById(R.id.category_featured);
    ImageView category_favourite = (ImageView) findViewById(R.id.category_favourite);
    category_daily.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            setRecyclerAdapter(recyclerView, 7);
            currentWallpaperCategory = WallpaperCategory.DAILY;
        }
    });
    category_featured.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            setRecyclerAdapter(recyclerView, 8);
            currentWallpaperCategory = WallpaperCategory.FEATURED;
        }
    });
    category_favourite.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            setRecyclerAdapter(recyclerView, 9);
            currentWallpaperCategory = WallpaperCategory.FAVOURITE;
        }
    });

    LinearLayout categoryWallpaper = (LinearLayout) findViewById(R.id.categoryButtonArrow);
    LinearLayout categoryAllWallpaper = (LinearLayout) findViewById(R.id.categoryWallpaper);
    LinearLayout kidsyWallpaperAction = (LinearLayout) findViewById(R.id.kidsyWallpaperAction);
    LinearLayout keepCalmWallpaperAction = (LinearLayout) findViewById(R.id.keepCalmWallpaperAction);
    LinearLayout romanticWallpaperAction = (LinearLayout) findViewById(R.id.romanticWallpaperAction);
    LinearLayout materialWallpaperAction = (LinearLayout) findViewById(R.id.materialWallpaperAction);
    categoryAllWallpaper.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            setRecyclerAdapter(recyclerView, 0);
            currentWallpaperCategory = WallpaperCategory.ALL;
        }
    });
    categoryWallpaper.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            categorySutterChange(600);
            //                YoYo.with(Techniques.RotateAntiClockWise)
            //                        .duration(300)
            //                        .interpolate(new AccelerateDecelerateInterpolator())
            //                        .withListener(new Animator.AnimatorListener() {
            //                            @Override
            //                            public void onAnimationStart(Animator animation) {
            //
            //                            }
            //
            //                            @Override
            //                            public void onAnimationEnd(Animator animation) {
            //
            //                            }
            //
            //                            @Override
            //                            public void onAnimationCancel(Animator animation) {
            //                                Toast.makeText(MainActivity.this, "canceled", Toast.LENGTH_SHORT).show();
            //                            }
            //
            //                            @Override
            //                            public void onAnimationRepeat(Animator animation) {
            //
            //                            }
            //                        })
            //                        .playOn(findViewById(R.id.categoryButtonArrow));
        }
    });
    kidsyWallpaperAction.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            openUri(PLAY_STORE_URL);
        }
    });
    keepCalmWallpaperAction.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            openUri(PLAY_STORE_URL);
        }
    });
    romanticWallpaperAction.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            openUri(PLAY_STORE_URL);
        }
    });
    materialWallpaperAction.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            openUri(PLAY_STORE_URL);
        }
    });

    //        Button button = (Button) findViewById(R.id.testButton);
    //        button.setOnClickListener(new View.OnClickListener() {
    //            @Override
    //            public void onClick(View v) {
    //                Typeface tf = Typeface.createFromAsset(getAssets(), "fonts/Roboto-LightItalic.ttf");
    //                SnackbarManager.show(
    //                        SnackBar.with(MainActivity.this)
    //                                .text("Something has been done")
    //                                .actionLabel("Undo")
    //                                .margin(15, 15)
    //                                .backgroundDrawable(R.drawable.custom_shape)
    //                                .actionLabelTypeface(tf)
    //                                .actionListener(new ActionClickListener() {
    //                                    @Override
    //                                    public void onActionClicked(SnackBar snackBar) {
    //                                        Toast.makeText(MainActivity.this,
    //                                                "Action undone",
    //                                                Toast.LENGTH_SHORT).show();
    //                                    }
    //                                }));
    //            }
    //        });

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        Window w = getWindow();
        w.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION,
                WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
        w.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS,
                WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    } else {
        // do something for lower version
    }

    recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            super.onScrolled(recyclerView, dx, dy);
            if (dy > 0 && isSearchOn && !isSearchAnimationRunning) {
                isSearchOn = false;
                isSearchAnimationRunning = true;
                YoYo.with(Techniques.ZoomOutPosition).duration(500)
                        .interpolate(new AccelerateDecelerateInterpolator())
                        .withListener(new Animator.AnimatorListener() {
                            @Override
                            public void onAnimationStart(Animator animation) {

                            }

                            @Override
                            public void onAnimationEnd(Animator animation) {
                                fabSearchWallpaper.setVisibility(View.GONE);
                                isSearchAnimationRunning = false;
                            }

                            @Override
                            public void onAnimationCancel(Animator animation) {
                                Toast.makeText(MainActivity.this, "canceled", Toast.LENGTH_SHORT).show();
                            }

                            @Override
                            public void onAnimationRepeat(Animator animation) {

                            }
                        }).playOn(findViewById(R.id.fab_search_wallpaper));
            } else if (dy < 0 && !isSearchOn && !isSearchAnimationRunning) {
                isSearchOn = true;
                isSearchAnimationRunning = true;
                fabSearchWallpaper.setVisibility(View.VISIBLE);
                YoYo.with(Techniques.ZoomInPosition).duration(500)
                        .interpolate(new AccelerateDecelerateInterpolator())
                        .withListener(new Animator.AnimatorListener() {
                            @Override
                            public void onAnimationStart(Animator animation) {

                            }

                            @Override
                            public void onAnimationEnd(Animator animation) {
                                isSearchAnimationRunning = false;
                            }

                            @Override
                            public void onAnimationCancel(Animator animation) {
                                Toast.makeText(MainActivity.this, "canceled", Toast.LENGTH_SHORT).show();
                            }

                            @Override
                            public void onAnimationRepeat(Animator animation) {

                            }
                        }).playOn(findViewById(R.id.fab_search_wallpaper));
            }
        }
    });

}

From source file:com.dish.browser.activity.BrowserActivity.java

@SuppressLint("NewApi")
@SuppressWarnings("deprecation")
private synchronized void initialize() {
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);//w w w  .ja va2  s  .  c  o  m
    ActionBar actionBar = getSupportActionBar();

    mPreferences = PreferenceManager.getInstance();
    mDarkTheme = mPreferences.getUseDarkTheme() || isIncognito();
    mActivity = this;
    mWebViews.clear();

    mClickHandler = new ClickHandler(this);
    mBrowserFrame = (FrameLayout) findViewById(R.id.content_frame);
    mToolbarLayout = (LinearLayout) findViewById(R.id.toolbar_layout);
    // initialize background ColorDrawable
    mBackground.setColor(((ColorDrawable) mToolbarLayout.getBackground()).getColor());

    mUiLayout = (LinearLayout) findViewById(R.id.ui_layout);
    mProgressBar = (AnimatedProgressBar) findViewById(R.id.progress_view);
    RelativeLayout newTab = (RelativeLayout) findViewById(R.id.new_tab_button);
    mDrawerLeft = (LinearLayout) findViewById(R.id.left_drawer);
    // Drawer stutters otherwise
    mDrawerLeft.setLayerType(View.LAYER_TYPE_HARDWARE, null);
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerListLeft = (ListView) findViewById(R.id.left_drawer_list);

    setNavigationDrawerWidth();

    mWebpageBitmap = Utils.getWebpageBitmap(getResources(), mDarkTheme);

    mHomepage = mPreferences.getHomepage();

    mTitleAdapter = new LightningViewAdapter(this, R.layout.tab_list_item, mWebViews);
    mDrawerListLeft.setAdapter(mTitleAdapter);
    mDrawerListLeft.setOnItemClickListener(new DrawerItemClickListener());
    mDrawerListLeft.setOnItemLongClickListener(new DrawerItemLongClickListener());

    mHistoryDatabase = HistoryDatabase.getInstance(getApplicationContext());

    // set display options of the ActionBar
    actionBar.setDisplayShowTitleEnabled(false);
    actionBar.setDisplayShowHomeEnabled(false);
    actionBar.setDisplayShowCustomEnabled(true);
    actionBar.setCustomView(R.layout.toolbar_content);

    View v = actionBar.getCustomView();
    LayoutParams lp = v.getLayoutParams();
    lp.width = LayoutParams.MATCH_PARENT;
    v.setLayoutParams(lp);

    mArrowDrawable = new DrawerArrowDrawable(this);
    mArrowImage = (ImageView) actionBar.getCustomView().findViewById(R.id.arrow);
    // Use hardware acceleration for the animation
    mArrowImage.setLayerType(View.LAYER_TYPE_HARDWARE, null);
    mArrowImage.setImageDrawable(mArrowDrawable);
    LinearLayout arrowButton = (LinearLayout) actionBar.getCustomView().findViewById(R.id.arrow_button);
    arrowButton.setOnClickListener(this);

    mI2PHelper = new I2PAndroidHelper(this);

    RelativeLayout back = (RelativeLayout) findViewById(R.id.action_back);
    back.setOnClickListener(this);

    RelativeLayout forward = (RelativeLayout) findViewById(R.id.action_forward);
    forward.setOnClickListener(this);

    // create the search EditText in the ToolBar
    mSearch = (AutoCompleteTextView) actionBar.getCustomView().findViewById(R.id.search);
    mUntitledTitle = getString(R.string.untitled);
    mBackgroundColor = getResources().getColor(R.color.primary_color);
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        mDeleteIcon = getResources().getDrawable(R.drawable.ic_action_delete);
        mRefreshIcon = getResources().getDrawable(R.drawable.ic_action_refresh);
        mCopyIcon = getResources().getDrawable(R.drawable.ic_action_copy);
    } else {
        Theme theme = getTheme();
        mDeleteIcon = getResources().getDrawable(R.drawable.ic_action_delete, theme);
        mRefreshIcon = getResources().getDrawable(R.drawable.ic_action_refresh, theme);
        mCopyIcon = getResources().getDrawable(R.drawable.ic_action_copy, theme);
    }

    int iconBounds = Utils.convertDpToPixels(24);
    mDeleteIcon.setBounds(0, 0, iconBounds, iconBounds);
    mRefreshIcon.setBounds(0, 0, iconBounds, iconBounds);
    mCopyIcon.setBounds(0, 0, iconBounds, iconBounds);
    mIcon = mRefreshIcon;
    SearchClass search = new SearchClass();
    mSearch.setCompoundDrawables(null, null, mRefreshIcon, null);
    mSearch.setOnKeyListener(search.new KeyListener());
    mSearch.setOnFocusChangeListener(search.new FocusChangeListener());
    mSearch.setOnEditorActionListener(search.new EditorActionListener());
    mSearch.setOnTouchListener(search.new TouchListener());

    mSystemBrowser = getSystemBrowser();
    Thread initialize = new Thread(new Runnable() {

        @Override
        public void run() {
            initializeSearchSuggestions(mSearch);
        }

    });
    initialize.run();

    newTab.setOnClickListener(this);
    newTab.setOnLongClickListener(new View.OnLongClickListener() {

        @Override
        public boolean onLongClick(View v) {
            String url = mPreferences.getSavedUrl();
            if (url != null) {
                newTab(url, true);
                Toast.makeText(mActivity, R.string.deleted_tab, Toast.LENGTH_SHORT).show();
            }
            mPreferences.setSavedUrl(null);
            return true;
        }

    });

    mDrawerLayout.setDrawerShadow(R.drawable.drawer_right_shadow, GravityCompat.END);
    mDrawerLayout.setDrawerShadow(R.drawable.drawer_left_shadow, GravityCompat.START);
    initializeTabs();

    if (API <= Build.VERSION_CODES.JELLY_BEAN_MR2) {
        WebIconDatabase.getInstance().open(getDir("icons", MODE_PRIVATE).getPath());
    }

    checkForProxy();
}

From source file:com.mobicage.rogerthat.plugins.messaging.ServiceMessageDetailActivity.java

protected void updateMessageDetail(final boolean isUpdate) {
    T.UI();// w  w  w  .  j  a v  a 2  s .  c o m
    // Set sender avatar
    ImageView avatarImage = (ImageView) findViewById(R.id.avatar);
    String sender = mCurrentMessage.sender;
    setAvatar(avatarImage, sender);
    // Set sender name
    TextView senderView = (TextView) findViewById(R.id.sender);
    final String senderName = mFriendsPlugin.getName(sender);
    senderView.setText(senderName == null ? sender : senderName);
    // Set timestamp
    TextView timestampView = (TextView) findViewById(R.id.timestamp);
    timestampView.setText(TimeUtils.getDayTimeStr(this, mCurrentMessage.timestamp * 1000));

    // Set clickable region on top to go to friends detail
    final RelativeLayout messageHeader = (RelativeLayout) findViewById(R.id.message_header);
    messageHeader.setOnClickListener(getFriendDetailOnClickListener(mCurrentMessage.sender));
    messageHeader.setVisibility(View.VISIBLE);

    // Set message
    TextView messageView = (TextView) findViewById(R.id.message);
    WebView web = (WebView) findViewById(R.id.webview);
    FrameLayout flay = (FrameLayout) findViewById(R.id.message_details);
    Resources resources = getResources();
    flay.setBackgroundColor(resources.getColor(R.color.mc_background));
    boolean showBranded = false;

    int darkSchemeTextColor = resources.getColor(android.R.color.primary_text_dark);
    int lightSchemeTextColor = resources.getColor(android.R.color.primary_text_light);

    senderView.setTextColor(lightSchemeTextColor);
    timestampView.setTextColor(lightSchemeTextColor);

    BrandingResult br = null;
    if (!TextUtils.isEmptyOrWhitespace(mCurrentMessage.branding)) {
        boolean brandingAvailable = false;
        try {
            brandingAvailable = mMessagingPlugin.getBrandingMgr().isBrandingAvailable(mCurrentMessage.branding);
        } catch (BrandingFailureException e1) {
            L.d(e1);
        }
        try {
            if (brandingAvailable) {
                br = mMessagingPlugin.getBrandingMgr().prepareBranding(mCurrentMessage);
                WebSettings settings = web.getSettings();
                settings.setJavaScriptEnabled(false);
                settings.setBlockNetworkImage(false);
                web.loadUrl("file://" + br.file.getAbsolutePath());
                web.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
                if (br.color != null) {
                    flay.setBackgroundColor(br.color);
                }
                if (!br.showHeader) {
                    messageHeader.setVisibility(View.GONE);
                    MarginLayoutParams mlp = (MarginLayoutParams) web.getLayoutParams();
                    mlp.setMargins(0, 0, 0, mlp.bottomMargin);
                } else if (br.scheme == ColorScheme.dark) {
                    senderView.setTextColor(darkSchemeTextColor);
                    timestampView.setTextColor(darkSchemeTextColor);
                }

                showBranded = true;
            } else {
                mMessagingPlugin.getBrandingMgr().queueGenericBranding(mCurrentMessage.branding);
            }
        } catch (BrandingFailureException e) {
            L.bug("Could not display message with branding: branding is available, but prepareBranding failed",
                    e);
        }
    }

    if (showBranded) {
        web.setVisibility(View.VISIBLE);
        messageView.setVisibility(View.GONE);
    } else {
        web.setVisibility(View.GONE);
        messageView.setVisibility(View.VISIBLE);
        messageView.setText(mCurrentMessage.message);
    }

    // Add list of members who did not ack yet
    FlowLayout memberSummary = (FlowLayout) findViewById(R.id.member_summary);
    memberSummary.removeAllViews();
    SortedSet<MemberStatusTO> memberSummarySet = new TreeSet<MemberStatusTO>(getMemberstatusComparator());
    for (MemberStatusTO ms : mCurrentMessage.members) {
        if ((ms.status & MessagingPlugin.STATUS_ACKED) != MessagingPlugin.STATUS_ACKED
                && !ms.member.equals(mCurrentMessage.sender)) {
            memberSummarySet.add(ms);
        }
    }
    FlowLayout.LayoutParams flowLP = new FlowLayout.LayoutParams(2, 0);
    for (MemberStatusTO ms : memberSummarySet) {
        FrameLayout fl = new FrameLayout(this);
        fl.setLayoutParams(flowLP);
        memberSummary.addView(fl);
        fl.addView(createParticipantView(ms));
    }
    memberSummary.setVisibility(memberSummarySet.size() < 2 ? View.GONE : View.VISIBLE);

    // Add members statuses
    final LinearLayout members = (LinearLayout) findViewById(R.id.members);
    members.removeAllViews();
    final String myEmail = mService.getIdentityStore().getIdentity().getEmail();
    boolean isMember = false;
    mSomebodyAnswered = false;
    for (MemberStatusTO ms : mCurrentMessage.members) {
        boolean showMember = true;
        View view = getLayoutInflater().inflate(R.layout.message_member_detail, null);
        // Set receiver avatar
        RelativeLayout rl = (RelativeLayout) view.findViewById(R.id.avatar);
        rl.addView(createParticipantView(ms));
        // Set receiver name
        TextView receiverView = (TextView) view.findViewById(R.id.receiver);
        final String memberName = mFriendsPlugin.getName(ms.member);
        receiverView.setText(memberName == null ? sender : memberName);
        // Set received timestamp
        TextView receivedView = (TextView) view.findViewById(R.id.received_timestamp);
        if ((ms.status & MessagingPlugin.STATUS_RECEIVED) == MessagingPlugin.STATUS_RECEIVED) {
            final String humanTime = TimeUtils.getDayTimeStr(this, ms.received_timestamp * 1000);
            if (ms.member.equals(mCurrentMessage.sender))
                receivedView.setText(getString(R.string.sent_at, humanTime));
            else
                receivedView.setText(getString(R.string.received_at, humanTime));
        } else {
            receivedView.setText(R.string.not_yet_received);
        }
        // Set replied timestamp
        TextView repliedView = (TextView) view.findViewById(R.id.acked_timestamp);
        if ((ms.status & MessagingPlugin.STATUS_ACKED) == MessagingPlugin.STATUS_ACKED) {
            mSomebodyAnswered = true;
            String acked_timestamp = TimeUtils.getDayTimeStr(this, ms.acked_timestamp * 1000);
            if (ms.button_id != null) {

                ButtonTO button = null;
                for (ButtonTO b : mCurrentMessage.buttons) {
                    if (b.id.equals(ms.button_id)) {
                        button = b;
                        break;
                    }
                }
                if (button == null) {
                    repliedView.setText(getString(R.string.dismissed_at, acked_timestamp));
                    // Do not show sender as member if he hasn't clicked a
                    // button
                    showMember = !ms.member.equals(mCurrentMessage.sender);
                } else {
                    repliedView.setText(getString(R.string.replied_at, button.caption, acked_timestamp));
                }
            } else {
                if (ms.custom_reply == null) {
                    // Do not show sender as member if he hasn't clicked a
                    // button
                    showMember = !ms.member.equals(mCurrentMessage.sender);
                    repliedView.setText(getString(R.string.dismissed_at, acked_timestamp));
                } else
                    repliedView.setText(getString(R.string.replied_at, ms.custom_reply, acked_timestamp));
            }
        } else {
            repliedView.setText(R.string.not_yet_replied);
            showMember = !ms.member.equals(mCurrentMessage.sender);
        }
        if (br != null && br.scheme == ColorScheme.dark) {
            receiverView.setTextColor(darkSchemeTextColor);
            receivedView.setTextColor(darkSchemeTextColor);
            repliedView.setTextColor(darkSchemeTextColor);
        } else {
            receiverView.setTextColor(lightSchemeTextColor);
            receivedView.setTextColor(lightSchemeTextColor);
            repliedView.setTextColor(lightSchemeTextColor);
        }

        if (showMember)
            members.addView(view);
        isMember |= ms.member.equals(myEmail);
    }

    boolean isLocked = (mCurrentMessage.flags & MessagingPlugin.FLAG_LOCKED) == MessagingPlugin.FLAG_LOCKED;
    boolean canEdit = isMember && !isLocked;

    // Add attachments
    LinearLayout attachmentLayout = (LinearLayout) findViewById(R.id.attachment_layout);
    attachmentLayout.removeAllViews();
    if (mCurrentMessage.attachments.length > 0) {
        attachmentLayout.setVisibility(View.VISIBLE);

        for (final AttachmentTO attachment : mCurrentMessage.attachments) {
            View v = getLayoutInflater().inflate(R.layout.attachment_item, null);

            ImageView attachment_image = (ImageView) v.findViewById(R.id.attachment_image);
            if (AttachmentViewerActivity.CONTENT_TYPE_JPEG.equalsIgnoreCase(attachment.content_type)
                    || AttachmentViewerActivity.CONTENT_TYPE_PNG.equalsIgnoreCase(attachment.content_type)) {
                attachment_image.setImageResource(R.drawable.attachment_img);
            } else if (AttachmentViewerActivity.CONTENT_TYPE_PDF.equalsIgnoreCase(attachment.content_type)) {
                attachment_image.setImageResource(R.drawable.attachment_pdf);
            } else if (AttachmentViewerActivity.CONTENT_TYPE_VIDEO_MP4
                    .equalsIgnoreCase(attachment.content_type)) {
                attachment_image.setImageResource(R.drawable.attachment_video);
            } else {
                attachment_image.setImageResource(R.drawable.attachment_unknown);
                L.d("attachment.content_type not known: " + attachment.content_type);
            }

            TextView attachment_text = (TextView) v.findViewById(R.id.attachment_text);
            attachment_text.setText(attachment.name);

            v.setOnClickListener(new SafeViewOnClickListener() {

                @Override
                public void safeOnClick(View v) {
                    String downloadUrlHash = mMessagingPlugin
                            .attachmentDownloadUrlHash(attachment.download_url);

                    File attachmentsDir;
                    try {
                        attachmentsDir = mMessagingPlugin.attachmentsDir(mCurrentMessage.getThreadKey(), null);
                    } catch (IOException e) {
                        L.d("Unable to create attachment directory", e);
                        UIUtils.showAlertDialog(ServiceMessageDetailActivity.this, "",
                                R.string.unable_to_read_write_sd_card);
                        return;
                    }

                    boolean attachmentAvailable = mMessagingPlugin.attachmentExists(attachmentsDir,
                            downloadUrlHash);

                    if (!attachmentAvailable) {
                        try {
                            attachmentsDir = mMessagingPlugin.attachmentsDir(mCurrentMessage.getThreadKey(),
                                    mCurrentMessage.key);
                        } catch (IOException e) {
                            L.d("Unable to create attachment directory", e);
                            UIUtils.showAlertDialog(ServiceMessageDetailActivity.this, "",
                                    R.string.unable_to_read_write_sd_card);
                            return;
                        }

                        attachmentAvailable = mMessagingPlugin.attachmentExists(attachmentsDir,
                                downloadUrlHash);
                    }

                    if (!mService.getNetworkConnectivityManager().isConnected() && !attachmentAvailable) {
                        AlertDialog.Builder builder = new AlertDialog.Builder(
                                ServiceMessageDetailActivity.this);
                        builder.setMessage(R.string.no_internet_connection_try_again);
                        builder.setPositiveButton(R.string.rogerthat, null);
                        AlertDialog dialog = builder.create();
                        dialog.show();
                        return;
                    }
                    if (IOUtils.shouldCheckExternalStorageAvailable()) {
                        String state = Environment.getExternalStorageState();
                        if (Environment.MEDIA_MOUNTED.equals(state)) {
                            // Its all oke
                        } else if (Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) {
                            if (!attachmentAvailable) {
                                L.d("Unable to write to sd-card");
                                UIUtils.showAlertDialog(ServiceMessageDetailActivity.this, "",
                                        R.string.unable_to_read_write_sd_card);
                                return;
                            }
                        } else {
                            L.d("Unable to read or write to sd-card");
                            UIUtils.showAlertDialog(ServiceMessageDetailActivity.this, "",
                                    R.string.unable_to_read_write_sd_card);
                            return;
                        }
                    }

                    L.d("attachment.content_type: " + attachment.content_type);
                    L.d("attachment.download_url: " + attachment.download_url);
                    L.d("attachment.name: " + attachment.name);
                    L.d("attachment.size: " + attachment.size);

                    if (AttachmentViewerActivity.supportsContentType(attachment.content_type)) {
                        Intent i = new Intent(ServiceMessageDetailActivity.this,
                                AttachmentViewerActivity.class);
                        i.putExtra("thread_key", mCurrentMessage.getThreadKey());
                        i.putExtra("message", mCurrentMessage.key);
                        i.putExtra("content_type", attachment.content_type);
                        i.putExtra("download_url", attachment.download_url);
                        i.putExtra("name", attachment.name);
                        i.putExtra("download_url_hash", downloadUrlHash);

                        startActivity(i);
                    } else {
                        AlertDialog.Builder builder = new AlertDialog.Builder(
                                ServiceMessageDetailActivity.this);
                        builder.setMessage(getString(R.string.attachment_can_not_be_displayed_in_your_version,
                                getString(R.string.app_name)));
                        builder.setPositiveButton(R.string.rogerthat, null);
                        AlertDialog dialog = builder.create();
                        dialog.show();
                    }
                }

            });

            attachmentLayout.addView(v);
        }

    } else {
        attachmentLayout.setVisibility(View.GONE);
    }

    LinearLayout widgetLayout = (LinearLayout) findViewById(R.id.widget_layout);
    if (mCurrentMessage.form == null) {
        widgetLayout.setVisibility(View.GONE);
    } else {
        widgetLayout.setVisibility(View.VISIBLE);
        widgetLayout.setEnabled(canEdit);
        displayWidget(widgetLayout, br);
    }

    // Add buttons
    TableLayout tableLayout = (TableLayout) findViewById(R.id.buttons);
    tableLayout.removeAllViews();

    for (final ButtonTO button : mCurrentMessage.buttons) {
        addButton(senderName, myEmail, mSomebodyAnswered, canEdit, tableLayout, button);
    }
    if (mCurrentMessage.form == null && (mCurrentMessage.flags
            & MessagingPlugin.FLAG_ALLOW_DISMISS) == MessagingPlugin.FLAG_ALLOW_DISMISS) {
        ButtonTO button = new ButtonTO();
        button.caption = "Roger that!";
        addButton(senderName, myEmail, mSomebodyAnswered, canEdit, tableLayout, button);
    }

    if (mCurrentMessage.broadcast_type != null) {
        L.d("Show broadcast spam control");
        final RelativeLayout broadcastSpamControl = (RelativeLayout) findViewById(R.id.broadcast_spam_control);
        View broadcastSpamControlBorder = findViewById(R.id.broadcast_spam_control_border);
        final View broadcastSpamControlDivider = findViewById(R.id.broadcast_spam_control_divider);

        final LinearLayout broadcastSpamControlTextContainer = (LinearLayout) findViewById(
                R.id.broadcast_spam_control_text_container);
        TextView broadcastSpamControlText = (TextView) findViewById(R.id.broadcast_spam_control_text);

        final LinearLayout broadcastSpamControlSettingsContainer = (LinearLayout) findViewById(
                R.id.broadcast_spam_control_settings_container);
        TextView broadcastSpamControlSettingsText = (TextView) findViewById(
                R.id.broadcast_spam_control_settings_text);
        TextView broadcastSpamControlIcon = (TextView) findViewById(R.id.broadcast_spam_control_icon);
        broadcastSpamControlIcon.setTypeface(mFontAwesomeTypeFace);
        broadcastSpamControlIcon.setText(R.string.fa_bell);

        final FriendBroadcastInfo fbi = mFriendsPlugin.getFriendBroadcastFlowForMfr(mCurrentMessage.sender);
        if (fbi == null) {
            L.bug("BroadcastData was null for: " + mCurrentMessage.sender);
            collapseDetails(DETAIL_SECTIONS);
            return;
        }
        broadcastSpamControl.setVisibility(View.VISIBLE);

        broadcastSpamControlSettingsContainer.setOnClickListener(new SafeViewOnClickListener() {

            @Override
            public void safeOnClick(View v) {
                L.d("goto broadcast settings");

                PressMenuIconRequestTO request = new PressMenuIconRequestTO();
                request.coords = fbi.coords;
                request.static_flow_hash = fbi.staticFlowHash;
                request.hashed_tag = fbi.hashedTag;
                request.generation = fbi.generation;
                request.service = mCurrentMessage.sender;
                mContext = "MENU_" + UUID.randomUUID().toString();
                request.context = mContext;
                request.timestamp = System.currentTimeMillis() / 1000;

                showTransmitting(null);
                Map<String, Object> userInput = new HashMap<String, Object>();
                userInput.put("request", request.toJSONMap());
                userInput.put("func", "com.mobicage.api.services.pressMenuItem");

                MessageFlowRun mfr = new MessageFlowRun();
                mfr.staticFlowHash = fbi.staticFlowHash;
                try {
                    JsMfr.executeMfr(mfr, userInput, mService, true);
                } catch (EmptyStaticFlowException ex) {
                    completeTransmit(null);
                    AlertDialog.Builder builder = new AlertDialog.Builder(ServiceMessageDetailActivity.this);
                    builder.setMessage(ex.getMessage());
                    builder.setPositiveButton(R.string.rogerthat, null);
                    AlertDialog dialog = builder.create();
                    dialog.show();
                    return;
                }
            }

        });

        UIUtils.showHint(this, mService, HINT_BROADCAST, R.string.hint_broadcast,
                mCurrentMessage.broadcast_type, mFriendsPlugin.getName(mCurrentMessage.sender));

        broadcastSpamControlText
                .setText(getString(R.string.broadcast_subscribed_to, mCurrentMessage.broadcast_type));
        broadcastSpamControlSettingsText.setText(fbi.label);
        int ligthAlpha = 180;
        int darkAlpha = 70;
        int alpha = ligthAlpha;
        if (br != null && br.scheme == ColorScheme.dark) {
            broadcastSpamControlIcon.setTextColor(getResources().getColor(android.R.color.black));
            broadcastSpamControlBorder.setBackgroundColor(darkSchemeTextColor);
            broadcastSpamControlDivider.setBackgroundColor(darkSchemeTextColor);
            activity.setBackgroundColor(darkSchemeTextColor);
            broadcastSpamControlText.setTextColor(lightSchemeTextColor);
            broadcastSpamControlSettingsText.setTextColor(lightSchemeTextColor);
            int alpacolor = Color.argb(darkAlpha, Color.red(lightSchemeTextColor),
                    Color.green(lightSchemeTextColor), Color.blue(lightSchemeTextColor));
            broadcastSpamControl.setBackgroundColor(alpacolor);

            alpha = darkAlpha;
        } else {
            broadcastSpamControlIcon.setTextColor(getResources().getColor(android.R.color.white));
            broadcastSpamControlBorder.setBackgroundColor(lightSchemeTextColor);
            broadcastSpamControlDivider.setBackgroundColor(lightSchemeTextColor);
            activity.setBackgroundColor(lightSchemeTextColor);
            broadcastSpamControlText.setTextColor(darkSchemeTextColor);
            broadcastSpamControlSettingsText.setTextColor(darkSchemeTextColor);
            int alpacolor = Color.argb(darkAlpha, Color.red(darkSchemeTextColor),
                    Color.green(darkSchemeTextColor), Color.blue(darkSchemeTextColor));
            broadcastSpamControl.setBackgroundColor(alpacolor);
        }

        if (br != null && br.color != null) {
            int alphaColor = Color.argb(alpha, Color.red(br.color), Color.green(br.color),
                    Color.blue(br.color));
            broadcastSpamControl.setBackgroundColor(alphaColor);
        }

        mService.postOnUIHandler(new SafeRunnable() {

            @Override
            protected void safeRun() throws Exception {
                int maxHeight = broadcastSpamControl.getHeight();
                broadcastSpamControlDivider.getLayoutParams().height = maxHeight;
                broadcastSpamControlDivider.requestLayout();

                broadcastSpamControlSettingsContainer.getLayoutParams().height = maxHeight;
                broadcastSpamControlSettingsContainer.requestLayout();

                broadcastSpamControlTextContainer.getLayoutParams().height = maxHeight;
                broadcastSpamControlTextContainer.requestLayout();

                int broadcastSpamControlWidth = broadcastSpamControl.getWidth();
                android.view.ViewGroup.LayoutParams lp = broadcastSpamControlSettingsContainer
                        .getLayoutParams();
                lp.width = broadcastSpamControlWidth / 4;
                broadcastSpamControlSettingsContainer.setLayoutParams(lp);
            }
        });
    }

    if (!isUpdate)
        collapseDetails(DETAIL_SECTIONS);
}