Android Open Source - HotSpot_Android Chatroom List Adapter






From Project

Back to project page HotSpot_Android.

License

The source code is released under:

GNU General Public License

If you think the Android project HotSpot_Android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.ticknardif.hotspot;
/* w  ww . j  a v a  2 s  .  c o  m*/
import android.content.Context;
import android.graphics.Typeface;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.List;

public class ChatroomListAdapter extends ArrayAdapter<Chatroom> {

    List<Chatroom> chatrooms;
    boolean showNearby = true;
    boolean showJoined = true;

    Typeface boldFont;

    public ChatroomListAdapter(Context context, int textViewResourceId) {
        super(context, textViewResourceId);
        this.chatrooms = new ArrayList<Chatroom>();
        boldFont = Typeface.createFromAsset(context.getAssets(), "fonts/Quicksand_Bold.otf");
    }

    public ChatroomListAdapter(Context context, int resource, List<Chatroom> chatrooms) {
        super(context, resource, chatrooms);
        this.chatrooms = chatrooms;
        boldFont = Typeface.createFromAsset(context.getAssets(), "fonts/Quicksand_Bold.otf");
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        View v = convertView;

        if(v == null) {
            LayoutInflater vi;
            vi = LayoutInflater.from(getContext());
            v = vi.inflate(R.layout.chatroom_list_item, null);
        }

        Chatroom chatroom = getItem(position);

        if (chatroom != null) {
            TextView titleTV = (TextView) v.findViewById(R.id.chatroom_title);

            if(titleTV != null) {
                titleTV.setText(chatroom.getTitle());
            }

            TextView memberTV = (TextView) v.findViewById(R.id.chatroom_member_status);

            if(memberTV != null) {
                String memberString = chatroom.isJoined() ? "Member" : "Not Member";
                memberTV.setText(memberString);
            }

            TextView descTV = (TextView) v.findViewById(R.id.chatroom_description);

            if(descTV != null) {
                descTV.setText(chatroom.getDescription());
            }

            Button button = (Button) v.findViewById(R.id.chatroom_enter_button);
            String buttonText = chatroom.isJoined() ? "Enter" : "Join";
            button.setText(buttonText);
            button.setTag(chatroom);
            button.setTypeface(boldFont);
        }

        return v;
    }

    public void toggleJoined() {
        showJoined = !showJoined;
        notifyDataSetChanged();
        Log.d("Debug", "Joined: " + showJoined + ", Nearby: " + showNearby);
    }

    public void toggleNearby() {
        showNearby = !showNearby;
        notifyDataSetChanged();
        Log.d("Debug", "Joined: " + showJoined + ", Nearby: " + showNearby);
    }
}




Java Source Code List

com.example.ticknardif.hotspot.ApplicationTest.java
com.example.ticknardif.hotspot.util.SystemUiHiderBase.java
com.example.ticknardif.hotspot.util.SystemUiHiderHoneycomb.java
com.example.ticknardif.hotspot.util.SystemUiHider.java
com.ticknardif.hotspot.AppStartActivity.java
com.ticknardif.hotspot.ChatroomActivity.java
com.ticknardif.hotspot.ChatroomListAdapter.java
com.ticknardif.hotspot.ChatroomOverlay.java
com.ticknardif.hotspot.Chatroom.java
com.ticknardif.hotspot.CreateAccountActivity.java
com.ticknardif.hotspot.CreateChatroomFragment.java
com.ticknardif.hotspot.GcmBroadcastReceiver.java
com.ticknardif.hotspot.GcmIntentService.java
com.ticknardif.hotspot.LoginActivity.java
com.ticknardif.hotspot.MainActivity.java
com.ticknardif.hotspot.MessageListAdapter.java
com.ticknardif.hotspot.Message.java
com.ticknardif.hotspot.WebService.java
com.ticknardif.hotspot.RESTresponses.ChatRoomCreationResponse.java
com.ticknardif.hotspot.RESTresponses.ChatroomResponse.java
com.ticknardif.hotspot.RESTresponses.ChatroomUserResponse.java
com.ticknardif.hotspot.RESTresponses.CreateChatroomResponse.java
com.ticknardif.hotspot.RESTresponses.GCMResponse.java
com.ticknardif.hotspot.RESTresponses.JoinChatroomResponse.java
com.ticknardif.hotspot.RESTresponses.LeaveChatroomResponse.java
com.ticknardif.hotspot.RESTresponses.LoginResponse.java
com.ticknardif.hotspot.RESTresponses.LogoutResponse.java
com.ticknardif.hotspot.RESTresponses.UpdateLocationResponse.java
com.ticknardif.hotspot.RESTresponses.UserResponse.java