Added Picasso library

Minor Bugfixes
This commit is contained in:
NudeDude 2018-01-21 21:21:41 +01:00
parent 7c8a18121a
commit 623fca48a5
14 changed files with 120 additions and 110 deletions

View File

@ -110,7 +110,7 @@ public class ProfileAction extends AsyncTask<Long,Void,Long>
description = user.getDescription();
location = user.getLocation();
link = user.getURL();
follower = "UserDetail: "+user.getFollowersCount();
follower = "Follower: "+user.getFollowersCount();
following = "Following: "+user.getFriendsCount();
imageLink = user.getProfileImageURL();
bannerLink = user.getProfileBannerMobileURL();

View File

@ -17,7 +17,6 @@ import java.io.InputStream;
import java.net.URL;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import twitter4j.MediaEntity;
@ -38,10 +37,10 @@ public class ShowStatus extends AsyncTask<Long, Void, Boolean> {
private Context c;
private Twitter twitter;
private ListView replyList;
private TextView username,scrName, replyName, tweet, txtRet, txtFav, date;
private TextView used_api, txtAns;
private Button retweetButton, favoriteButton;
private ImageView profile_img, tweet_img;
private TextView username,scrName,replyName,tweet;
private TextView used_api,txtAns,txtRet,txtFav,date;
private Button retweetButton,favoriteButton;
private ImageView profile_img,tweet_img;
private ArrayList<twitter4j.Status> answers;
private String usernameStr, scrNameStr, tweetStr, dateString;
private String ansStr, rtStr, favStr, repliedUsername, apiName;
@ -49,7 +48,6 @@ public class ShowStatus extends AsyncTask<Long, Void, Boolean> {
private SharedPreferences settings;
private int load, ansNo = 0;
private long userReply, tweetReplyID;
private Date d;
private Bitmap profile_btm, tweet_btm;
public ShowStatus(Context c) {
@ -95,7 +93,6 @@ public class ShowStatus extends AsyncTask<Long, Void, Boolean> {
currentTweet = retweetedStat;
rtFlag = true;
}
rtStr = Integer.toString(currentTweet.getRetweetCount());
favStr = Integer.toString(currentTweet.getFavoriteCount());
userReply = currentTweet.getInReplyToUserId();
@ -112,9 +109,9 @@ public class ShowStatus extends AsyncTask<Long, Void, Boolean> {
if(userReply > 0) {
repliedUsername = "Antwort an @"+currentTweet.getInReplyToScreenName();
}
d = currentTweet.getCreatedAt();
SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy hh:mm:ss");
dateString = sdf.format(d);
dateString = sdf.format(currentTweet.getCreatedAt());
Query query = new Query("to:"+scrNameStr+" since_id:"+tweetID+" -filter:retweets");
query.setCount(load);
@ -135,7 +132,7 @@ public class ShowStatus extends AsyncTask<Long, Void, Boolean> {
} else {
if(id[1]==RETWEET) {
if(retweeted) {
//TODO destroy Retweet
// TODO del Retweet
} else {
twitter.retweetStatus(tweetID);
retweeted = true;
@ -151,8 +148,10 @@ public class ShowStatus extends AsyncTask<Long, Void, Boolean> {
}
return false;
}
} catch(Exception err){ err.printStackTrace(); }
return true;
} catch(Exception err) {
err.printStackTrace();
return false;
}
}
@Override

View File

@ -3,15 +3,19 @@ package org.nuclearfog.twidda.backend;
import android.content.Context;
import android.os.AsyncTask;
import android.support.v4.widget.SwipeRefreshLayout;
import android.view.View;
import android.widget.ListView;
import android.widget.ProgressBar;
import org.nuclearfog.twidda.database.UserDatabase;
import org.nuclearfog.twidda.R;
import org.nuclearfog.twidda.viewadapter.UserAdapter;
import org.nuclearfog.twidda.window.UserDetail;
import java.util.ArrayList;
import java.util.List;
import twitter4j.IDs;
import twitter4j.Twitter;
import twitter4j.User;
@ -21,7 +25,7 @@ public class UserLists extends AsyncTask <Long, Void, Void> {
private Twitter twitter;
private UserAdapter usrAdp;
private ListView userList;
private SwipeRefreshLayout userReload;
private ProgressBar uProgress;
/**
*@see UserDetail
@ -34,7 +38,7 @@ public class UserLists extends AsyncTask <Long, Void, Void> {
protected void onPreExecute() {
twitter = TwitterResource.getInstance(context).getTwitter();
userList = (ListView)((UserDetail)context).findViewById(R.id.followList);
userReload = (SwipeRefreshLayout)((UserDetail)context).findViewById(R.id.follow_swipe);
uProgress = (ProgressBar)((UserDetail)context).findViewById(R.id.user_progress);
}
/**
@ -45,18 +49,27 @@ public class UserLists extends AsyncTask <Long, Void, Void> {
long mode = data[0];
long id = data[1];
long cursor = -1L; //TODO
List<User> userlist = null;
List<User> listUser = null;
try {
if(mode == 0L) { //FOLLOWING
userlist = twitter.getFollowersList(id,cursor);
} else if(mode == 1L) { //Follower
userlist = twitter.getFriendsList(id,cursor);
} else if(mode == 2L) { // Retweet TODO
} else if(mode == 3L) { // Favorite TODO
if(mode == 0L) { // GET FOLLOWING USERS
listUser = twitter.getFriendsList(id,cursor);
}
if(userlist != null)
usrAdp = new UserAdapter(context,new UserDatabase(context,userlist));
} catch(Exception err) {
else if(mode == 1L) { // GET FOLLOWER
listUser = twitter.getFollowersList(id,cursor);
}
else if(mode == 2L) { // GET RETWEET USER
IDs retweeter = twitter.getRetweeterIds(id, cursor);
listUser = new ArrayList<>();
for(long userId : retweeter.getIDs()) {
listUser.add(twitter.showUser(userId));
}
}
else if(mode == 3L) { // GET FAV USERS TODO
}
if(listUser != null)
usrAdp = new UserAdapter(context,new UserDatabase(context,listUser));
}
catch(Exception err) {
err.printStackTrace();
}
return null;
@ -65,6 +78,6 @@ public class UserLists extends AsyncTask <Long, Void, Void> {
@Override
protected void onPostExecute(Void v) {
userList.setAdapter(usrAdp);
userReload.setRefreshing(false);
uProgress.setVisibility(View.INVISIBLE);
}
}

View File

@ -5,7 +5,6 @@ import android.content.Context;
import android.content.SharedPreferences;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.graphics.Bitmap;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
@ -27,7 +26,6 @@ public class TweetDatabase {
private List<Long> userId,tweetId,timeMillis;
private List<Integer> noRT,noFav,noAns;
private List<Status> stats;
private List<Bitmap> profileImg;
private SharedPreferences settings;
private boolean toggleImg;
private int size = 0;
@ -185,10 +183,6 @@ public class TweetDatabase {
db.close();
}
public void setPbList(List<Bitmap> profileImg) {
this.profileImg = profileImg;
}
public int getSize() {
return size;
}
@ -204,7 +198,6 @@ public class TweetDatabase {
public String getDate(int pos){return timeToString(getTime(pos));}
public String getPbLink (int pos){return pbLink.get(pos);}
public boolean loadImages(){return toggleImg;}
public Bitmap getProfileImg(int pos){return profileImg.get(pos);}
/**
* Convert Time to String

View File

@ -2,6 +2,7 @@ package org.nuclearfog.twidda.viewadapter;
import android.content.Context;
import android.support.annotation.NonNull;
import android.text.SpannableString;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

View File

@ -25,7 +25,7 @@ public class UserAdapter extends ArrayAdapter implements View.OnClickListener {
private Context context;
public UserAdapter(Context context, UserDatabase userDatabase) {
super(context, R.layout.user);
super(context, R.layout.useritem);
this.userDatabase = userDatabase;
this.context = context;
inf = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
@ -47,7 +47,7 @@ public class UserAdapter extends ArrayAdapter implements View.OnClickListener {
public View getView(int position, View v, @NonNull ViewGroup parent) {
p = parent;
if(v == null) {
v = inf.inflate(R.layout.user, parent,false);
v = inf.inflate(R.layout.useritem, parent,false);
v.setBackgroundColor(background);
v.setOnClickListener(this);
}

View File

@ -16,9 +16,11 @@ public class ColorPreferences implements OnColorChangedListener, DialogInterface
public static final int BACKGROUND = 0x0;
public static final int FONT_COLOR = 0x1;
public static final int HIGHLIGHTING = 0x2;
public static final int TWEET_COLOR = 0x3;
private int background = 0;
private int highlight = 0;
private int font = 0;
private int tweet = 0;
private int mode;
@ -32,6 +34,7 @@ public class ColorPreferences implements OnColorChangedListener, DialogInterface
background = settings.getInt("background_color", 0xff061a22);
font = settings.getInt("font_color", 0xffffffff);
tweet = settings.getInt("tweet_color", 0xff19aae8);
highlight = settings.getInt("highlight_color", 0xffff00ff);
}
@Override
@ -43,6 +46,9 @@ public class ColorPreferences implements OnColorChangedListener, DialogInterface
case FONT_COLOR:
font = newColor;
break;
case HIGHLIGHTING:
highlight = newColor;
case TWEET_COLOR:
tweet = newColor;
break;
@ -67,6 +73,8 @@ public class ColorPreferences implements OnColorChangedListener, DialogInterface
return font;
case TWEET_COLOR:
return tweet;
case HIGHLIGHTING:
return highlight;
default:
return -1;
}
@ -85,6 +93,9 @@ public class ColorPreferences implements OnColorChangedListener, DialogInterface
case(TWEET_COLOR):
preColor = tweet;
break;
case HIGHLIGHTING:
preColor = highlight;
break;
default:
preColor = 0xFFFFFFFF;
}
@ -101,6 +112,7 @@ public class ColorPreferences implements OnColorChangedListener, DialogInterface
e.putInt("background_color", background);
e.putInt("font_color", font);
e.putInt("tweet_color", tweet);
e.putInt("highlight_color", highlight);
e.apply();
}

View File

@ -19,19 +19,17 @@ import org.nuclearfog.twidda.viewadapter.UserAdapter;
* Get Follow Connections from an User
* @see UserLists
*/
public class UserDetail extends AppCompatActivity implements AdapterView.OnItemClickListener,
SwipeRefreshLayout.OnRefreshListener {
public class UserDetail extends AppCompatActivity implements AdapterView.OnItemClickListener {
private long userID, tweetID;
private long mode;
private ListView userListview;
private SwipeRefreshLayout reload;
private Toolbar toolbar;
@Override
protected void onCreate(Bundle b) {
super.onCreate(b);
setContentView(R.layout.follow);
setContentView(R.layout.user);
Intent i = getIntent();
userID = i.getExtras().getLong("userID");
mode = i.getExtras().getLong("mode");
@ -40,42 +38,32 @@ public class UserDetail extends AppCompatActivity implements AdapterView.OnItemC
}
userListview = (ListView) findViewById(R.id.followList);
reload = (SwipeRefreshLayout) findViewById(R.id.follow_swipe);
userListview.setOnItemClickListener(this);
toolbar = (Toolbar) findViewById(R.id.follow_toolbar);
setSupportActionBar(toolbar);
setActionbarTitle(mode);
userListview.setOnItemClickListener(this);
reload.setOnRefreshListener(this);
getUsers();
}
@Override
public boolean onCreateOptionsMenu( Menu m ) {
toolbar.inflateMenu(R.menu.setting); //TODO
toolbar.inflateMenu(R.menu.setting); // TODO
return true;
}
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
if(!reload.isRefreshing()) {
UserAdapter uAdp = (UserAdapter) userListview.getAdapter();
UserDatabase uDB = uAdp.getAdapter();
long userID = uDB.getUserID(position);
Intent intent = new Intent(getApplicationContext(), UserProfile.class);
Bundle bundle = new Bundle();
bundle.putLong("userID",userID);
bundle.putBoolean("home", false);//todo
intent.putExtras(bundle);
startActivity(intent);
}
UserAdapter uAdp = (UserAdapter) userListview.getAdapter();
UserDatabase uDB = uAdp.getAdapter();
long userID = uDB.getUserID(position);
Intent intent = new Intent(getApplicationContext(), UserProfile.class);
Bundle bundle = new Bundle();
bundle.putLong("userID",userID);
intent.putExtras(bundle);
startActivity(intent);
}
@Override
public void onRefresh() {
getUsers();
}
private void getUsers(){
private void getUsers() {
UserLists uList = new UserLists(UserDetail.this);
if(mode == 0L || mode == 1L) {
uList.execute(mode, userID);

View File

@ -211,7 +211,7 @@ public class UserProfile extends AppCompatActivity implements View.OnClickListen
}
/**
* @param mode 0L = Following , 1L UserDetail
* @param mode 0L = Following , 1L Follower
*/
private void getFollows(long mode) {
Intent intent = new Intent(getApplicationContext(), UserDetail.class);

View File

@ -1,23 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.Toolbar
android:id="@+id/follow_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize" />
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/follow_swipe"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="@+id/followList"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</android.support.v4.widget.SwipeRefreshLayout>
</LinearLayout>

View File

@ -9,10 +9,6 @@
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin">
<!-- user name label -->
<!-- Twitter Login Button -->
<Button
android:id="@+id/linkButton"
android:layout_width="180dp"

View File

@ -68,6 +68,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center" />
</TabHost>

View File

@ -1,34 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:contentDescription="@string/profile_image"
android:padding="5dp">
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/user_profileimg"
android:layout_width="64dp"
android:layout_height="64dp"
android:contentDescription="@string/profile_image"
android:padding="5dp" />
<android.support.v7.widget.Toolbar
android:id="@+id/follow_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize" />
<LinearLayout
<FrameLayout
android:id="@+id/userframe"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/username_detail"
android:layout_width="match_parent"
<ProgressBar
android:id="@+id/user_progress"
style="?android:attr/progressBarStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10" />
android:layout_gravity="center" />
<TextView
android:id="@+id/screenname_detail"
<ListView
android:id="@+id/followList"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10" />
android:layout_height="match_parent" />
</FrameLayout>
</LinearLayout>
</LinearLayout>

View File

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:contentDescription="@string/profile_image"
android:padding="5dp">
<ImageView
android:id="@+id/user_profileimg"
android:layout_width="64dp"
android:layout_height="64dp"
android:contentDescription="@string/profile_image"
android:padding="5dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/username_detail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10" />
<TextView
android:id="@+id/screenname_detail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10" />
</LinearLayout>
</LinearLayout>