表白墙简单APP

原创 2016年06月01日 20:31:21

最近楼主为了找工作也是绞尽脑汁,想着不如写个开源APP增加一下人气,于是表白墙APP的设计与实现就应运而生了。效果图如下:




说起来这个APP没什么特别的,也就是集成了Bmob后台加上一些开源框架,架构采用了MVP设计架构,说起来自己写的还不算真正的MVP,因为我写完之后发现还可以进一步重构和简化,大量使用泛型解决接口回调---该死谁让我Java写的这么细碎了。。不过后期我也懒得去改了。首先说下思路吧:
一个表白墙APP那么就应该会有上传文字图片的基本功能,所以就会有一个表白的类,我定义为:MessageWall;
这个类的基本属性如下:
private String Confess_content;//表白内容
private String Confess_image;//表白图片
private int Collection_count;//被收藏的数目
private int Comment_count;//被评论的数目
private int Support_count;//被赞的数目
private boolean Is_Anonymous;//是否匿名
private User user;//表白者

其次就是用户类:User;
public class User extends BmobUser implements Serializable{
    private String sex;
    private String nick;
    private Integer age;
    private String tel;
    private String icon;
    //用户收藏夹
    private BmobRelation likes;
    //好友
    private BmobRelation friends;
    private BmobRelation tricks;
    //经纬度坐标
    private BmobGeoPoint gpsadd;
    //地理位置
    private String address;


    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public BmobGeoPoint getGpsadd() {
        return gpsadd;
    }

    public void setGpsadd(BmobGeoPoint gpsadd) {
        this.gpsadd = gpsadd;
    }

    public BmobRelation getTricks() {
        return tricks;
    }

    public void setTricks(BmobRelation tricks) {
        this.tricks = tricks;
    }

    public BmobRelation getFriends() {
        return friends;
    }

    public void setFriends(BmobRelation friends) {
        this.friends = friends;
    }

    public BmobRelation getLikes() {
        return likes;
    }

    public void setLikes(BmobRelation likes) {
        this.likes = likes;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public String getNick() {
        return nick;
    }

    public void setNick(String nick) {
        this.nick = nick;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public String getTel() {
        return tel;
    }

    public void setTel(String tel) {
        this.tel = tel;
    }

    public String getIcon() {
        return icon;
    }

    public void setIcon(String icon) {
        this.icon = icon;
    }
}
没啥可说的。当然有了用户,有了表白内容就会想到有评论:Comment,基本属性如下:
private String content;
private User user;
private MessageWall messageWall;
楼主为了追求高大上添加了什么类型QQ聊天功能啊,消息推送功能啊,第三方登录功能啊,定位功能啊。。。反正加着加着就觉得细碎了。
ChattingMsg是聊天的表格,记录聊天内容;属性如下:
private String uid1;
private String uid2;
private int type;//0代表发送的,1代表接受的消息
private String content;//消息内容
LocationInfo是地理位置对象,有三个属性:
/**
 * 经度
 */
private double latitude;
/**
 * 纬度
 */
private double longtitude;
private String address;
Suggestion是反馈建议表,基本属性如下:
private User user;
private String advice;
有了这些实体类model就可以构造我们的Biz也就是业务层啦,,,
业务层主要分为关于User和关于MessageWall的两个业务层,那么就会为UserBiz声明一个IUserBiz接口,让UserBiz去实现这个接口,,
不要问我为什么这么做,如果你还想让你的代码解耦,清楚明了的话你就听我一言吧。。这方面代码太多我就贴一个比较有代表性的UserBiz吧:下面是IuserBiz接口方法:
//登录
 void login(String username, String password, OnLoginListener loginListener, Context context);
 //第三方登录
 void  third_login(String uid,String nickname,String icon,OnLoginListener loginListener,Context context);
 //注册
 void register(String username, String password, String email, OnRegisterListener registerListener, Context context);
//忘记密码
 void rememberpds(String email, OnRememberPsdListener onRememberPsdListener, Context context);
 //更新User基本信息
 void UpdateUserData(User user, String nick, String sex, int age, String tel, OnUpdateListener updateListener, Context context);
//上传User头像
 void UpdateUserIcon(User user, String iconpath, OnUpdateListener updateListener, Context context);
 //添加收藏
 void CollectionOp(User user, MessageWall messageWall, OnUpdateListener updateListener, Context context);
 //取消收藏
 void DelCollection(User user, MessageWall messageWall, OnUpdateListener updateListener, Context context);
 //查找我的收藏
 void QueryMyCollectionData(int page,User user,OnQueryListener queryListener,Context context);


 void CreateFriendObject(String friendId,OnCreateFriendListener createFriendListener,Context context);
 //添加好友
 void AddFriends(User user,String friendId,OnAddFriendsListener addFriendsListener,Context context);
 void AddFriends2(User user,User friend,OnAddFriendsListener addFriendsListener,Context context);
 void DelFriends(User user,User friend,OnAddFriendsListener addFriendsListener,Context context);

 //查找我的好友
 void QueryFriends(int page,User user,OnQueryFriendsListener queryFriendsListener,Context context);
//查找附近好友
 void QueryNearFriends(int page,BmobGeoPoint gpsadd,OnQueryFriendsListener queryFriendsListener,Context context);


 void QueryUserById(String userId,OnQueryUserByIdListener queryUserByIdListener,Context context);

//更新地理位置
 void UpdateLocation(User user,LocationInfo locationInfo,OnUpdateGspListener onUpdateGspListener,Context context);
这样写就很清楚明了啦!那么UserBiz也懒得贴了,贴了你也懒得看。。。
说道MVP还没有说清楚是吧,,好的就见一个比较牛掰的案例:即时聊天效果如下:
GIF.gif
要实现这么一个功能,想都不要想需要一个推送功能的API,目前有什么友盟啊,极光啊推送一大堆,但是楼主懒得去找,发现Bmob也有自己的推送就直接集成过来,然后改造就实现了这么个功能:如下是一个推送广播接受。。。。暂时试看前面介收得到msg即可。。。
public class MyPushMessageReceiver extends BroadcastReceiver {
   public static MsgGosn msgGosn;
   private PushMessageReceiverPresenter presenter;
   @Override
   public void onReceive(final Context context, Intent intent) {
      if (intent.getAction().equals(PushConstants.ACTION_MESSAGE)) {
         String msg = intent
               .getStringExtra(PushConstants.EXTRA_PUSH_MESSAGE_STRING);
         Log.e("bmob", "客户端收到推送内容:" + msg);
          String content = null;
         try {
            JSONObject object=new JSONObject(msg);
            content= object.getString("alert");
            Gson gson=new Gson();
            msgGosn=gson.fromJson(content, MsgGosn.class);
            //添加好友邀请
            if (msgGosn.isaddfriend()==true){
               CustomDialog.Builder builder = new CustomDialog.Builder(context);
               builder.setMessage("“"+msgGosn.getNick()+"”"+"想添加你为好友");
               builder.setTitle("表白墙APP");
               builder.setPositiveButton("添加", new DialogInterface.OnClickListener() {
                  public void onClick(DialogInterface dialog, int which) {
                     dialog.dismiss();
                     //添加好友操作
                     presenter=new PushMessageReceiverPresenter(context,msgGosn);
                            presenter.ReceiveRequest();
                  }
               });
               builder.setNegativeButton("拒绝",
                     new android.content.DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int which) {
                           dialog.dismiss();
                        }
                     });
               CustomDialog ad = builder.create();
               ad.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
               ad.setCanceledOnTouchOutside(false);                                   //点击外面区域不会让dialog消失
               ad.show();
                   return;
            }
            if (msgGosn.isRecieveaddfriend()==true){
               //收到好友邀请之后。。。
               presenter=new PushMessageReceiverPresenter(context,msgGosn);
               presenter.RequestSuccess();
               return;
            }
         } catch (JSONException e) {
            e.printStackTrace();
         }
            //说明这个Activity在栈顶
         if (ShowChattingMsgActivity.class!=null&&ShowChattingMsgActivity.chattingMsgs!=null) {
            ShowChattingMsgActivity.getRequest(msgGosn);
         }else {
            //否则使用通知栏信息通知提示
            NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
            Notification.Builder builder = new Notification.Builder(context);
            Intent mIntent = new Intent(context, ShowChattingMsgActivity.class);
            mIntent.putExtra("friend_user_icon", msgGosn.getIcon());
            mIntent.putExtra("friend_user_id", msgGosn.getId());
            PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, mIntent, 0);
            builder.setContentIntent(pendingIntent);
            builder.setLargeIcon(BitmapFactory.decodeResource(context.getResources(), R.drawable.wall));
            if (TextUtils.isEmpty(msgGosn.getNick())) {
               builder.setContentTitle("LoveWall");
            } else {
               builder.setContentTitle(msgGosn.getNick());
            }
            builder.setSmallIcon(R.drawable.icon_to_send);
            builder.setAutoCancel(true);
            builder.setContentText(msgGosn.getMsg());
            notificationManager.notify(0, builder.build());
         }
      }
   }
}
说MVP就是将mv分开更清楚些,让原来的control变为现在presenter,那么首先就会有个IView的接口;如下:
public interface IShowChattingMsgView {
    String  getSendMsg();
    void  SetRecieveMsg();
    void EmptyOfReplyMsg();
    User getCurrentUser();
    void ReplySuccess(String msg);
    void SetEmptyOfMsg();

    void InitFriendsData();
    void NeedLogin();

    void UpdateAdapter(int size, List<ChattingMsg> IchattingMsgs);
    void LoadOver();
}
然后让Activity去继承IView,就变得如下代码了:
public class ShowChattingMsgActivity extends Activity implements View.OnClickListener, IShowChattingMsgView{....}
之后就会有个presenter,如下:
public class ShowChattingPresenter {
    private Context context;
    private IShowChattingMsgView lookTrickView;
    private IUserBiz userBiz;
    private IChattingMsgBiz msgBiz;

    public ShowChattingPresenter(Context context, IShowChattingMsgView lookTrickView) {
        msgBiz=new ChattingMsgBiz();
        this.userBiz = new UserBiz();
        this.context = context;
        this.lookTrickView = lookTrickView;
    }
}
在回到Activity中去声明这个presenter:
private ShowChattingPresenter  presenter=new ShowChattingPresenter(ShowChattingMsgActivity.this,this);
主要关键是presenter里面的方法:
//回复消息,,首先保存消息---在推送消息给对方
public void replyMsg(String uid1, final String uid2) {
        if (lookTrickView.getCurrentUser() == null) {
            lookTrickView.NeedLogin();
            return;
        }
        if (TextUtils.isEmpty(lookTrickView.getSendMsg())) {
            lookTrickView.EmptyOfReplyMsg();
            return;
        }
       final   String msg=lookTrickView.getSendMsg();
        msgBiz.SaveMsgs(uid1, uid2, msg, new OnSaveMsgsListener() {
            @Override
            public void OnSuccess() {
                lookTrickView.SetEmptyOfMsg();
                PushMessage(uid2,msg);
                lookTrickView.ReplySuccess(msg);
            }
            @Override
            public void OnFailed() {
                T.showShort(context,"发送消息失败!");
            }
        },context);
    }

    //推送消息对方
    public void PushMessage(String uid2,String msg){
        BmobPushManager bmobPush = new BmobPushManager(context);
        BmobQuery<MyBmobInstallation> query = MyBmobInstallation.getQuery();
        query.addWhereEqualTo("uid", uid2);
        bmobPush.setQuery(query);
        MsgGosn msgGosn = new MsgGosn();
        msgGosn.setId(lookTrickView.getCurrentUser().getObjectId());
        msgGosn.setNick(lookTrickView.getCurrentUser().getNick());
        msgGosn.setMsg(msg);
        msgGosn.setIcon(lookTrickView.getCurrentUser().getIcon());
        Gson gson = new Gson();
        bmobPush.pushMessage(gson.toJson(msgGosn));
    }


    //上拉刷新加载,查询更多历史消息。。
    public List<ChattingMsg> PullDownRefreshqueryData(int page,String uid1,String uid2,final Context context) {
        final   List<ChattingMsg>messageWalls=new ArrayList<>();
        msgBiz.QueryMsgs(page, uid1,uid2,new OnQueryChattingMsgListener() {
            @Override
            public void Success(List<ChattingMsg> list) {
                if (list.size() > 0) {
                    //添加时候倒叙插入
                    for (int i=list.size()-1;i>=0;i--) {
                        messageWalls.add(list.get(i));
                    }
                    lookTrickView.UpdateAdapter(2, messageWalls);
                } else {
                    lookTrickView.UpdateAdapter(3, messageWalls);
                }
            }

            @Override
            public void Failure() {
                lookTrickView.UpdateAdapter(0, messageWalls);
            }
        }, context);
        return messageWalls;
    }

   //第一次加载数据。。。
    public List<ChattingMsg> FirstLoadingData(Context context,String uid1,String uid2) {
        final   List<ChattingMsg>messageWalls=new ArrayList<>();
        msgBiz.QueryMsgs(0, uid1,uid2,new OnQueryChattingMsgListener() {
            @Override
            public void Success(List<ChattingMsg> list) {
                if (list.size() > 0) {
                    messageWalls.clear();
                    for (int i=list.size()-1;i>=0;i--) {
                        messageWalls.add(list.get(i));
                    }
                    lookTrickView.UpdateAdapter(1, messageWalls);
                } else {
                    lookTrickView.UpdateAdapter(1, messageWalls);
                }
            }

            @Override
            public void Failure() {
                lookTrickView.UpdateAdapter(0, messageWalls);
            }
        }, context);
        return messageWalls;
    }
IChattingMsgBiz ChattingMsgBiz 会有对应的保存和查找消息两个方法,如下:
public interface IChattingMsgBiz {
    void QueryMsgs(int page,String uid1,String uid2,OnQueryChattingMsgListener queryListener,Context context);
    void SaveMsgs(String uid1,String uid2,String content,OnSaveMsgsListener saveMsgsListener,Context context);
}

public class ChattingMsgBiz implements IChattingMsgBiz {
    @Override
    public void QueryMsgs(int page,String uid1, String uid2, final OnQueryChattingMsgListener queryListener, Context context) {
        //条件一情况And
        BmobQuery<ChattingMsg> eq1 = new BmobQuery<ChattingMsg>();
        eq1.addWhereEqualTo("uid1", uid1);
        eq1.addWhereEqualTo("uid2", uid2);

        //条件2情况And
        BmobQuery<ChattingMsg> eq2 = new BmobQuery<ChattingMsg>();
        eq2.addWhereEqualTo("uid2", uid1);
        eq2.addWhereEqualTo("uid1", uid2);


        //条件一或者条件二合并情况OR
        List<BmobQuery<ChattingMsg>> queries = new ArrayList<>();
        queries.add(eq1);
        queries.add(eq2);

        BmobQuery<ChattingMsg> mainQuery = new BmobQuery<ChattingMsg>();
        mainQuery.or(queries);
        mainQuery.order("-createdAt");
        mainQuery.setLimit(10);
        mainQuery.setSkip(page * 10);
        mainQuery.findObjects(context, new FindListener<ChattingMsg>() {
            @Override
            public void onSuccess(List<ChattingMsg> list) {
                queryListener.Success(list);
            }

            @Override
            public void onError(int i, String s) {
                queryListener.Failure();
            }
        });
    }

    @Override
    public void SaveMsgs(String uid1, String uid2, String content, final OnSaveMsgsListener saveMsgsListener, Context context) {
        ChattingMsg msg = new ChattingMsg();
        msg.setUid1(uid1);
        msg.setUid2(uid2);
        msg.setContent(content);
        msg.save(context, new SaveListener() {
            @Override
            public void onSuccess() {
                saveMsgsListener.OnSuccess();
            }

            @Override
            public void onFailure(int i, String s) {
                saveMsgsListener.OnFailed();
            }
        });

    }
}
最后回到对于的Activity代码:
public class ShowChattingMsgActivity extends Activity implements View.OnClickListener, IShowChattingMsgView{
    @Bind(R.id.back)
    ImageView back;
    @Bind(R.id.mRefresh)
    MaterialRefreshLayout mRefresh;
    @Bind(R.id.comment_msg)
    EditText commentMsg;
    @Bind(R.id.submit)
    FloatingActionButton submit;
    private ShowChattingPresenter  presenter=new ShowChattingPresenter(ShowChattingMsgActivity.this,this);
    private static ChattingAdapter adapter;
    public static List<ChattingMsg> chattingMsgs;
    private String friend_user_icon;
    private String friend_user_id;
    private int currentpage = 1;
    private static  String uid;
    private static  ListView mListView;



    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.looktrick_main);
        ButterKnife.bind(this);
        mListView= (ListView) findViewById(R.id.mListView);
        friend_user_icon = (String) getIntent().getSerializableExtra("friend_user_icon");
        friend_user_id = (String) getIntent().getSerializableExtra("friend_user_id");
        uid=getCurrentUser().getObjectId();
        submit.setOnClickListener(this);
        back.setOnClickListener(this);
        chattingMsgs=new ArrayList<>();
        adapter=new ChattingAdapter(chattingMsgs,this,getCurrentUser().getIcon(),friend_user_icon,getCurrentUser().getObjectId());
        mListView.setAdapter(adapter);

        new Thread(new Runnable() {
            @Override
            public void run() {
                presenter.FirstLoadingData(ShowChattingMsgActivity.this,getCurrentUser().getObjectId(),friend_user_id);
                currentpage = 1;
            }
        }).start();
        //刷新加载数据
        mRefresh.setMaterialRefreshListener(new MaterialRefreshListener() {
            @Override
            public void onRefresh(MaterialRefreshLayout materialRefreshLayout) {
                //下拉刷新...与第一次加载数据一样
                presenter.PullDownRefreshqueryData(currentpage, getCurrentUser().getObjectId(), friend_user_id, ShowChattingMsgActivity.this);
            }

            @Override
            public void onRefreshLoadMore(MaterialRefreshLayout materialRefreshLayout) {
                //上拉刷新...

                // 结束上拉刷新...
            }
        });
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.submit:
                presenter.replyMsg(getCurrentUser().getObjectId(),friend_user_id);
                break;
            case R.id.back:
                ShowChattingMsgActivity.this.finish();
                break;
        }
    }

    @Override
    public String getSendMsg() {
        return commentMsg.getText().toString();
    }

    @Override
    public void SetRecieveMsg() {

    }

    @Override
    public void EmptyOfReplyMsg() {
        T.showShort(this, "回复内容不能为空");
    }

    @Override
    public User getCurrentUser() {
        return BmobUser.getCurrentUser(this, User.class);
    }

    @Override
    public void ReplySuccess(String msg) {
        ChattingMsg chattingMsg=new ChattingMsg();
        chattingMsg.setUid1(uid);
        chattingMsg.setUid2(friend_user_id);
        chattingMsg.setContent(msg);
        chattingMsgs.add(chattingMsg);
        adapter.notifyDataSetChanged();
        mListView.setSelection(adapter.getCount());
    }

    @Override
    public void SetEmptyOfMsg() {
        commentMsg.setText("");
    }

    //初始化信息
    @Override
    public void InitFriendsData() {

    }

    @Override
    public void NeedLogin() {
        T.showShort(this, "请先登录呦!");
    }

    @Override
    public void UpdateAdapter(int size, List<ChattingMsg> IchattingMsgs) {
        if (size==0){
        }else if (size==1){
            chattingMsgs.addAll(IchattingMsgs);
            if (chattingMsgs.size()>0){
                adapter.notifyDataSetChanged();
                mListView.setSelection(adapter.getCount());
            }else {
//                T.showShort(getApplicationContext(), "没有数据!");
            }
        }else  if (size==2){
            if (chattingMsgs.size() > 0) {
                chattingMsgs.addAll(0, IchattingMsgs);
                adapter.notifyDataSetChanged();
                currentpage++;
            }
        }else  if (size==3){
            T.showShort(getApplicationContext(), "没有更多聊天内容了!");
               LoadOver();
    }

    @Override
    public void LoadOver() {
        if (mRefresh!=null) {
            mRefresh.finishRefresh();
            mRefresh.finishRefreshLoadMore();
        }
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        presenter = null;
        chattingMsgs=null;
    }
}
我们会发现Activity的点击事件会触发Presenter里面的方法,,然后Presenter网络操作或者耗时操作完毕之后会调用IView接口方法,因为Activity继承了IView接口方法,,那么具体操作就可以在Presenter的接口回调成功也就是我们定义的OnSuccess回调去更新Activity数据:例如下:
public List<ChattingMsg> FirstLoadingData(Context context,String uid1,String uid2) {
        final   List<ChattingMsg>messageWalls=new ArrayList<>();
        msgBiz.QueryMsgs(0, uid1,uid2,new OnQueryChattingMsgListener() {
            @Override
            public void Success(List<ChattingMsg> list) {
                if (list.size() > 0) {
                    messageWalls.clear();
                    for (int i=list.size()-1;i>=0;i--) {
                        messageWalls.add(list.get(i));
                    }
                    lookTrickView.UpdateAdapter(1, messageWalls);//更新数据操作。。。
                } else {
                    lookTrickView.UpdateAdapter(1, messageWalls);//更新数据操作。。。
                }
            }

            @Override
            public void Failure() {
                lookTrickView.UpdateAdapter(0, messageWalls);//更新数据操作。。。
            }
        }, context);
        return messageWalls;
    }
//更新数据操作。。。
  @Override
    public void UpdateAdapter(int size, List<ChattingMsg> IchattingMsgs) {
        if (size==0){
        }else if (size==1){
            chattingMsgs.addAll(IchattingMsgs);
            if (chattingMsgs.size()>0){
                adapter.notifyDataSetChanged();
                mListView.setSelection(adapter.getCount());
            }else {
//                T.showShort(getApplicationContext(), "没有数据!");
            }
        }else  if (size==2){
            if (chattingMsgs.size() > 0) {
                chattingMsgs.addAll(0, IchattingMsgs);
                adapter.notifyDataSetChanged();
                currentpage++;
            }
        }else  if (size==3){
            T.showShort(getApplicationContext(), "没有更多聊天内容了!");
        }
        LoadOver();
    }
聪明的我们发现这样写好nice啊,增加业务时候在IBi和Biz增加,然后Presenter添加一个方法,最后Activity就可以去简单调用Presenter方法就可,再也不要那么烦躁的改Activity代码啦。。。
说完了MVP在说下第三方登录实现吧,,首先采用友盟或者ShareSDk提供的第三方登录的工具包呗,然后就直接按文档来实现。。。
不是我说友盟,,实在友盟的文档有点莫名其妙,官网提供的Demo还有问题,然后楼主果断换了shareSDK,实现思路就是先登录获取到UId之后就注册这个用户:
Activity代码:
mUserLoginPresenter.Third_login(mPlatform.getDb().getUserId(),mPlatform.getDb().getUserName(),mPlatform.getDb().getUserIcon());
mPlatform.removeAccount();
之后Presenter:
public  void Third_login(final String uid, final String nickname, final String icon){
    userBiz.third_login(uid, nickname, icon, new OnLoginListener() {
        @Override
        public void OnSuccess(User user) {
           //跳转页面去设置页面去。。。说明是第一次登录
            userBiz.login(uid, uid, new OnLoginListener() {
                @Override
                public void OnSuccess(User user) {
                   userLoginView.toSettingAty(nickname,icon);
                }

                @Override
                public void OnFailed() {
                    userLoginView.showFailedError();
                }
            }, userLoginView.getContext());
        }

        @Override
        public void OnFailed() {
            //跳转页面去设置页面去。。。说明不是第一次登录直接登录跳转
            userBiz.login(uid, uid, new OnLoginListener() {
                @Override
                public void OnSuccess(User user) {
                    userLoginView.toHomeActivity(user);
                }

                @Override
                public void OnFailed() {
                    userLoginView.showFailedError();
                }
            }, userLoginView.getContext());
        }
    },context);
}
去注册这个用户:UserBiz代码:
@Override
public void third_login(String uid, String nickname, String icon, final OnLoginListener loginListener, Context context) {
    User user=new User();
    user.setUsername(uid);
    user.setPassword(uid);
    user.setEmail(uid + "@163.com");
    user.setNick(nickname);
    user.setIcon(icon);
    user.signUp(context, new SaveListener() {
        @Override
        public void onSuccess() {
            loginListener.OnSuccess(null);
        }

        @Override
        public void onFailure(int i, String s) {
            //第三方注册失败说明,这个账号已经注册过了直接可以登录成功即可。。。
            loginListener.OnFailed();
        }
    });
}
其中注册失败不是代码登录不成功,相反是代表这个用户已经注册过了直接就跳到主页面去,,如果第一次注册就会到Onsuccess接口会执行
 userLoginView.toSettingAty(nickname,icon);方法。
最后附上我的开源APP的效果图和github地址:https://github.com/1036711153/ConfessWall
aGIF.gif
版权声明:本文为博主原创文章,未经博主允许不得转载。

相关文章推荐

浅谈属性动画简单使用之实现爱的贝塞尔曲线浪漫告白效果(三)

谁说程序员不浪漫的啊,每次看到别人在黑程序员心中就有一种无奈,只是他们看到的是程序员不好的一面,今天我将用这个案例告诉那些人,程序猿也是一个很浪漫,很有情调的人。在程序员心中他们只想做最高效的事情,没...

程序员表白程序,开放源码,不断更新(第二篇)

表白第一弹的内容发出去后,收到很多人的祝福和建议,很感谢大家的捧场,2014年经历了很多事,自己的创业路失败,重新找工作,一直忙碌,也没有再修改代码,现准备重新拾起来,把第一弹完善,然后送出表白第二弹...

表白程序源码,android

android表白程序,有源码。欢迎下载

程序员表白神器。安卓程序员表白软件。程序员追女友利器=android+雪花效果+彩色气泡+心形花园+心形玫瑰花+相爱天数计时器

程序员表白神器。安卓程序员表白软件。程序员追女友利器=android+雪花效果+彩色气泡+心形花园

打造浪漫的Android表白程序

几年前,看到过有个牛人用HTML5绘制了浪漫的爱心表白动画。地址在这:浪漫程序员 HTML5爱心表白动画。发现原来程序员也是可以很浪……漫…..的(PS:刚过520,被妹子骂不够浪漫)。那么在Andr...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:深度学习:神经网络中的前向传播和反向传播算法推导
举报原因:
原因补充:

(最多只允许输入30个字)