Android Open Source - Music-Share-Android Auth Manager Dialog Fragment From Project Back to project page Music-Share-Android .
License The source code is released under:
GNU General Public License
If you think the Android project Music-Share-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.paperairplane.music.share.dialogs;
/ * f r o m w w w . j a v a 2 s . c o m * /
import java.text.DateFormat;
import java.util.Date;
import com.paperairplane.music.share.Consts;
import com.paperairplane.music.share.Consts.SNS;
import com.paperairplane.music.share.R;
import com.paperairplane.music.share.SnsHelper;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
public class AuthManagerDialogFragment extends AbsDialogFragment {
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
ListView v = new ListView(getActivity());
v.setAdapter(new BaseAdapter(){
@Override
public int getCount() {
return 2;
}
@Override
public Object getItem(int arg0) {
return null;
}
@Override
public long getItemId(int arg0) {
return 0;
}
@Override
public View getView(int id, View arg1, ViewGroup arg2) {
View vItem = LayoutInflater.from(getActivity()).inflate(R.layout.sns_list_item, null);
ImageView ivIcon = (ImageView) vItem.findViewById(R.id.icon);
ImageView ivDelete = (ImageView) vItem.findViewById(R.id.clear);
TextView tvName = (TextView)vItem.findViewById(android.R.id.text1);
TextView tvTime = (TextView)vItem.findViewById(android.R.id.text2);
String name = null;
long time=0 ;
SharedPreferences preferences = getActivity().getApplicationContext().getSharedPreferences(Consts.Preferences.WEIBO,
Context.MODE_APPEND);
final SnsHelper sh = SnsHelper.getInstance();
switch (id){
case 0:
ivIcon.setImageResource(R.drawable.weibo_logo);
name = preferences.getString(SNS.WEIBO.name()+"name" ,null);
time = preferences.getLong(SNS.WEIBO.name()+"expiresTime" , 0);
vItem.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v) {
sh.authorize(getActivity(),SNS.WEIBO);
}
});
ivDelete.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View arg0) {
sh.unauthorize(SNS.WEIBO);
}
});
break ;
case 1:
ivIcon.setImageResource(R.drawable.renren_logo);
name = preferences.getString(SNS.RENREN.name()+"name" , null);
time = preferences.getLong(SNS.RENREN.name()+"expiresTime" , 0);
vItem.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v) {
sh.authorize(getActivity(),SNS.RENREN);
}
});
ivDelete.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View arg0) {
sh.unauthorize(SNS.RENREN);
}
});
break ;
}
DateFormat df = DateFormat.getDateTimeInstance();
Date date = new Date(time);
String formattedTime = df.format(date);
tvTime .setText(getString(R.string.expires_time)+formattedTime);
if (name == null){
name = getString(R.string.auth);
tvTime.setVisibility(View.GONE);
ivDelete.setVisibility(View.GONE);
}
tvName.setText(name);
return vItem;
}
});
Dialog dialog = new AlertDialog.Builder(getActivity())
.setTitle(R.string.account_manager)
.setView(v)
.create();
return dialog;
}
}
Java Source Code List android.net.http.SslError.java com.paperairplane.music.share.AtSuggestionActivity.java com.paperairplane.music.share.Consts.java com.paperairplane.music.share.FeedbackMessage.java com.paperairplane.music.share.Main.java com.paperairplane.music.share.MusicData.java com.paperairplane.music.share.MusicListAdapter.java com.paperairplane.music.share.QueryAndShareMusicInfo.java com.paperairplane.music.share.Receiver.java com.paperairplane.music.share.SnsHelper.java com.paperairplane.music.share.cache.ImageLoader.java com.paperairplane.music.share.cache.MemoryCache.java com.paperairplane.music.share.dialogs.AboutDialogFragment.java com.paperairplane.music.share.dialogs.AbsDialogFragment.java com.paperairplane.music.share.dialogs.AuthManagerDialogFragment.java com.paperairplane.music.share.dialogs.BackgroundChooserDialogFragment.java com.paperairplane.music.share.dialogs.ChangeColorDialogFragment.java com.paperairplane.music.share.dialogs.EmptyDialogFragment.java com.paperairplane.music.share.dialogs.FeedbackDialogFragment.java com.paperairplane.music.share.dialogs.SearchDialogFragment.java com.paperairplane.music.share.dialogs.SendWeiboDialogFragment.java com.paperairplane.music.share.dialogs.ThankDialogFragment.java com.paperairplane.music.share.utils.CrashHandler.java com.paperairplane.music.share.utils.HanziToPinyin.java com.paperairplane.music.share.utils.HttpQuestHandler.java com.paperairplane.music.share.utils.IntentResolver.java com.paperairplane.music.share.utils.MyLogger.java com.paperairplane.music.share.utils.ShakeDetector.java com.paperairplane.music.share.utils.Utilities.java com.paperairplane.music.share.utils.lastfm.Album.java com.paperairplane.music.share.utils.lastfm.Artist.java com.paperairplane.music.share.utils.lastfm.Caller.java com.paperairplane.music.share.utils.lastfm.DomElement.java com.paperairplane.music.share.utils.lastfm.ImageHolder.java com.paperairplane.music.share.utils.lastfm.ImageSize.java com.paperairplane.music.share.utils.lastfm.Image.java com.paperairplane.music.share.utils.lastfm.ItemFactoryBuilder.java com.paperairplane.music.share.utils.lastfm.ItemFactory.java com.paperairplane.music.share.utils.lastfm.MapUtilities.java com.paperairplane.music.share.utils.lastfm.MusicEntry.java com.paperairplane.music.share.utils.lastfm.PaginatedResult.java com.paperairplane.music.share.utils.lastfm.ResponseBuilder.java com.paperairplane.music.share.utils.lastfm.Result.java com.paperairplane.music.share.utils.lastfm.StringUtilities.java com.paperairplane.music.share.utils.lastfm.Track.java com.weibo.sdk.android.Oauth2AccessToken.java com.weibo.sdk.android.WeiboAuthListener.java com.weibo.sdk.android.WeiboDialogError.java com.weibo.sdk.android.WeiboDialog.java com.weibo.sdk.android.WeiboException.java com.weibo.sdk.android.WeiboParameters.java com.weibo.sdk.android.Weibo.java com.weibo.sdk.android.api.AccountAPI.java com.weibo.sdk.android.api.ActivityInvokeAPI.java com.weibo.sdk.android.api.CommentsAPI.java com.weibo.sdk.android.api.CommonAPI.java com.weibo.sdk.android.api.FavoritesAPI.java com.weibo.sdk.android.api.FriendshipsAPI.java com.weibo.sdk.android.api.PlaceAPI.java com.weibo.sdk.android.api.RegisterAPI.java com.weibo.sdk.android.api.SearchAPI.java com.weibo.sdk.android.api.ShortUrlAPI.java com.weibo.sdk.android.api.StatusesAPI.java com.weibo.sdk.android.api.SuggestionsAPI.java com.weibo.sdk.android.api.TagsAPI.java com.weibo.sdk.android.api.TrendsAPI.java com.weibo.sdk.android.api.UsersAPI.java com.weibo.sdk.android.api.WeiboAPI.java com.weibo.sdk.android.net.AsyncWeiboRunner.java com.weibo.sdk.android.net.HttpManager.java com.weibo.sdk.android.net.NetStateManager.java com.weibo.sdk.android.net.RequestListener.java com.weibo.sdk.android.sso.SsoHandler.java com.weibo.sdk.android.util.BitmapHelper.java com.weibo.sdk.android.util.Utility.java