mirror of
https://github.com/nuclearfog/Shitter.git
synced 2025-01-29 02:19:35 +01:00
code cleanup
This commit is contained in:
parent
eca6fb718d
commit
be101c5fd7
@ -255,7 +255,7 @@ public class MainActivity extends AppCompatActivity implements OnRefreshListener
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemClick(View v, ViewGroup parent, int position) {
|
||||
public void onItemClick(ViewGroup parent, int position) {
|
||||
switch(parent.getId()) {
|
||||
case R.id.tl_list:
|
||||
if(!timelineReload.isRefreshing()) {
|
||||
|
@ -30,13 +30,20 @@ import twitter4j.TwitterException;
|
||||
|
||||
public class ProfileLoader extends AsyncTask<Long,Void,Long> {
|
||||
|
||||
public static final long GET_INFORMATION = 0; //Profilinformation
|
||||
public static final long ACTION_FOLLOW = 1; // Folgen/Entfolgen
|
||||
public static final long GET_TWEETS = 2; // Tweets Laden
|
||||
public static final long GET_FAVS = 3; // Favoriten Laden
|
||||
// GET INFORMATION
|
||||
public static final long GET_INF = 0;
|
||||
public static final long LOAD_DB = 1;
|
||||
|
||||
// GET USER TWEETS
|
||||
public static final long GET_TWEETS = 2;
|
||||
public static final long GET_FAVORS = 3;
|
||||
|
||||
// USER ACTION
|
||||
public static final long ACTION_FOLLOW = 6;
|
||||
public static final long ACTION_BLOCK = 4;
|
||||
public static final long ACTION_MUTE = 5;
|
||||
public static final long LOAD_DB = 6;
|
||||
|
||||
// INTERN FLAGS
|
||||
private static final long FAILURE = 7;
|
||||
private static final long IGNORE = 8;
|
||||
|
||||
@ -102,7 +109,7 @@ public class ProfileLoader extends AsyncTask<Long,Void,Long> {
|
||||
long id = 1L;
|
||||
try {
|
||||
isHome = homeId == userId;
|
||||
if (!isHome && (MODE == ACTION_FOLLOW || MODE == ACTION_BLOCK || MODE == ACTION_MUTE || MODE == GET_INFORMATION))
|
||||
if (!isHome && (MODE == ACTION_FOLLOW || MODE == ACTION_BLOCK || MODE == ACTION_MUTE || MODE == GET_INF))
|
||||
{
|
||||
boolean connection[] = mTwitter.getConnection(userId);
|
||||
isFollowing = connection[0];
|
||||
@ -112,7 +119,7 @@ public class ProfileLoader extends AsyncTask<Long,Void,Long> {
|
||||
}
|
||||
|
||||
TwitterUser user;
|
||||
if(MODE == GET_INFORMATION) {
|
||||
if (MODE == GET_INF) {
|
||||
user = mTwitter.getUser(userId);
|
||||
database.storeUser(user);
|
||||
} else {
|
||||
@ -137,7 +144,6 @@ public class ProfileLoader extends AsyncTask<Long,Void,Long> {
|
||||
if (MODE == GET_TWEETS && !isLocked)
|
||||
{
|
||||
List<Tweet> tweets;
|
||||
|
||||
if(homeTl.getItemCount() > 0) {
|
||||
id = homeTl.getItemId(0);
|
||||
tweets = mTwitter.getUserTweets(userId,args[2],id);
|
||||
@ -151,7 +157,7 @@ public class ProfileLoader extends AsyncTask<Long,Void,Long> {
|
||||
}
|
||||
}
|
||||
homeTl.setData(tweets);
|
||||
} else if (MODE == GET_FAVS && !isLocked)
|
||||
} else if (MODE == GET_FAVORS && !isLocked)
|
||||
{
|
||||
List<Tweet> favorits;
|
||||
if(homeFav.getItemCount() > 0) {
|
||||
@ -203,8 +209,7 @@ public class ProfileLoader extends AsyncTask<Long,Void,Long> {
|
||||
final UserProfile connect = ui.get();
|
||||
if(connect == null)
|
||||
return;
|
||||
|
||||
if(mode == GET_INFORMATION || mode == LOAD_DB) {
|
||||
if (mode == GET_INF || mode == LOAD_DB) {
|
||||
TextView txtUser = connect.findViewById(R.id.profile_username);
|
||||
TextView txtScrName = connect.findViewById(R.id.profile_screenname);
|
||||
TextView txtBio = connect.findViewById(R.id.bio);
|
||||
@ -250,18 +255,14 @@ public class ProfileLoader extends AsyncTask<Long,Void,Long> {
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
else if(mode == GET_TWEETS)
|
||||
{
|
||||
} else if (mode == GET_TWEETS) {
|
||||
homeTl.notifyDataSetChanged();
|
||||
SwipeRefreshLayout tweetsReload = connect.findViewById(R.id.hometweets);
|
||||
tweetsReload.setRefreshing(false);
|
||||
}
|
||||
else if(mode == GET_FAVS)
|
||||
{
|
||||
} else if (mode == GET_FAVORS) {
|
||||
homeFav.notifyDataSetChanged();
|
||||
SwipeRefreshLayout favoritsReload = connect.findViewById(R.id.homefavorits);
|
||||
favoritsReload.setRefreshing(false);
|
||||
SwipeRefreshLayout favorReload = connect.findViewById(R.id.homefavorits);
|
||||
favorReload.setRefreshing(false);
|
||||
}
|
||||
else if(mode == ACTION_FOLLOW) {
|
||||
int textId;
|
||||
@ -296,7 +297,7 @@ public class ProfileLoader extends AsyncTask<Long,Void,Long> {
|
||||
Toast.makeText(connect, errMsg, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
if (!isHome && (mode == ACTION_FOLLOW || mode == ACTION_BLOCK || mode == ACTION_MUTE || mode == GET_INFORMATION)) {
|
||||
if (!isHome && (mode == ACTION_FOLLOW || mode == ACTION_BLOCK || mode == ACTION_MUTE || mode == GET_INF)) {
|
||||
Toolbar tool = connect.findViewById(R.id.profile_toolbar);
|
||||
if(tool.getMenu().size() >= 2) {
|
||||
MenuItem followIcon = tool.getMenu().getItem(1);
|
||||
|
@ -46,13 +46,6 @@ public class AppDatabase extends SQLiteOpenHelper
|
||||
|
||||
@Override
|
||||
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
||||
db.execSQL("DROP TABLE IF EXISTS " + "user");
|
||||
db.execSQL("DROP TABLE IF EXISTS " + "tweet");
|
||||
|
||||
db.execSQL("DROP TABLE IF EXISTS " + "favorit");
|
||||
|
||||
db.execSQL("DROP TABLE IF EXISTS " + "trend");
|
||||
db.execSQL("DROP TABLE IF EXISTS " + "error");
|
||||
}
|
||||
|
||||
|
||||
|
@ -45,7 +45,6 @@ public class DatabaseAdapter {
|
||||
public void storeUser(TwitterUser user) {
|
||||
SQLiteDatabase db = dataHelper.getWritableDatabase();
|
||||
storeUser(user, db);
|
||||
db.close();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -58,7 +57,6 @@ public class DatabaseAdapter {
|
||||
Tweet tweet = home.get(pos);
|
||||
storeStatus(tweet, homeMask, db);
|
||||
}
|
||||
db.close();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -71,7 +69,6 @@ public class DatabaseAdapter {
|
||||
Tweet tweet = mentions.get(pos);
|
||||
storeStatus(tweet, mentionMask, db);
|
||||
}
|
||||
db.close();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -84,7 +81,6 @@ public class DatabaseAdapter {
|
||||
Tweet tweet = stats.get(pos);
|
||||
storeStatus(tweet, userTweetMask, db);
|
||||
}
|
||||
db.close();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -102,7 +98,6 @@ public class DatabaseAdapter {
|
||||
favTable.put("ownerID", ownerId);
|
||||
db.insertWithOnConflict("favorit",null,favTable,CONFLICT_IGNORE);
|
||||
}
|
||||
db.close();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -115,7 +110,6 @@ public class DatabaseAdapter {
|
||||
Tweet tweet = replies.get(pos);
|
||||
storeStatus(tweet, replyMask, db);
|
||||
}
|
||||
db.close();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -125,7 +119,6 @@ public class DatabaseAdapter {
|
||||
public void storeFavorite(Tweet tweet) {
|
||||
SQLiteDatabase db = dataHelper.getWritableDatabase();
|
||||
storeStatus(tweet, favoritedMask, db);
|
||||
db.close();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -143,7 +136,6 @@ public class DatabaseAdapter {
|
||||
if (cursor.moveToFirst())
|
||||
user = getUser(cursor);
|
||||
cursor.close();
|
||||
db.close();
|
||||
return user;
|
||||
}
|
||||
|
||||
@ -166,7 +158,6 @@ public class DatabaseAdapter {
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
cursor.close();
|
||||
db.close();
|
||||
return tweetList;
|
||||
}
|
||||
|
||||
@ -189,7 +180,6 @@ public class DatabaseAdapter {
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
cursor.close();
|
||||
db.close();
|
||||
return tweetList;
|
||||
}
|
||||
|
||||
@ -215,7 +205,6 @@ public class DatabaseAdapter {
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
cursor.close();
|
||||
db.close();
|
||||
return tweetList;
|
||||
}
|
||||
|
||||
@ -239,7 +228,6 @@ public class DatabaseAdapter {
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
cursor.close();
|
||||
db.close();
|
||||
return tweetList;
|
||||
}
|
||||
|
||||
@ -259,7 +247,6 @@ public class DatabaseAdapter {
|
||||
if(cursor.moveToFirst())
|
||||
result = getStatus(cursor);
|
||||
cursor.close();
|
||||
db.close();
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -283,7 +270,6 @@ public class DatabaseAdapter {
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
cursor.close();
|
||||
db.close();
|
||||
return tweetList;
|
||||
}
|
||||
|
||||
@ -309,7 +295,6 @@ public class DatabaseAdapter {
|
||||
status.put("favorite",tweet.favorit);
|
||||
status.put("statusregister",register);
|
||||
db.update("tweet",status,"tweet.tweetID="+tweet.tweetID,null);
|
||||
db.close();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -319,7 +304,6 @@ public class DatabaseAdapter {
|
||||
public void removeStatus(long id) {
|
||||
SQLiteDatabase db = dataHelper.getWritableDatabase();
|
||||
db.delete("tweet","tweetID="+id,null);
|
||||
db.close();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -337,7 +321,6 @@ public class DatabaseAdapter {
|
||||
ContentValues status = new ContentValues();
|
||||
status.put("statusregister", register);
|
||||
db.update("tweet", status, "tweet.tweetID=" + tweetId, null);
|
||||
db.close();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -351,7 +334,6 @@ public class DatabaseAdapter {
|
||||
Cursor c = db.rawQuery(query,null);
|
||||
boolean result = c.moveToFirst();
|
||||
c.close();
|
||||
db.close();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -77,7 +77,7 @@ public class TrendRecycler extends Adapter<TrendRecycler.ItemHolder>
|
||||
ViewGroup p = TrendRecycler.this.parent;
|
||||
RecyclerView rv = (RecyclerView) p;
|
||||
int position = rv.getChildLayoutPosition(view);
|
||||
mListener.onItemClick(view, p, position);
|
||||
mListener.onItemClick(p, position);
|
||||
}
|
||||
|
||||
|
||||
@ -95,6 +95,6 @@ public class TrendRecycler extends Adapter<TrendRecycler.ItemHolder>
|
||||
* Custom Click Listener
|
||||
*/
|
||||
public interface OnItemClicked {
|
||||
void onItemClick(View v, ViewGroup parent, int position);
|
||||
void onItemClick(ViewGroup parent, int position);
|
||||
}
|
||||
}
|
@ -95,7 +95,7 @@ public class UserRecycler extends Adapter<UserRecycler.ItemHolder> implements On
|
||||
ViewGroup p = UserRecycler.this.parent;
|
||||
RecyclerView rv = (RecyclerView) p;
|
||||
int position = rv.getChildLayoutPosition(view);
|
||||
mListener.onItemClick(view, p, position);
|
||||
mListener.onItemClick(p, position);
|
||||
}
|
||||
|
||||
|
||||
@ -114,6 +114,6 @@ public class UserRecycler extends Adapter<UserRecycler.ItemHolder> implements On
|
||||
|
||||
|
||||
public interface OnItemClicked {
|
||||
void onItemClick(View v, ViewGroup parent, int position);
|
||||
void onItemClick(ViewGroup parent, int position);
|
||||
}
|
||||
}
|
@ -138,7 +138,7 @@ public class SearchPage extends AppCompatActivity implements UserRecycler.OnItem
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemClick(View view, ViewGroup parent, int position) {
|
||||
public void onItemClick(ViewGroup parent, int position) {
|
||||
Intent intent;
|
||||
switch(parent.getId()) {
|
||||
case R.id.tweet_result:
|
||||
|
@ -184,7 +184,7 @@ public class TweetDetail extends AppCompatActivity implements OnClickListener,
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemClick(View view, ViewGroup parent, int position) {
|
||||
public void onItemClick(ViewGroup parent, int position) {
|
||||
TimelineRecycler timeLineAdapter = (TimelineRecycler) answer_list.getAdapter();
|
||||
if (timeLineAdapter != null) {
|
||||
Tweet tweet = timeLineAdapter.getData().get(position);
|
||||
|
@ -8,7 +8,6 @@ import android.support.v7.widget.RecyclerView;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import org.nuclearfog.twidda.R;
|
||||
@ -72,7 +71,7 @@ public class UserDetail extends AppCompatActivity implements OnItemClicked {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemClick(View view, ViewGroup parent, int position) {
|
||||
public void onItemClick(ViewGroup parent, int position) {
|
||||
UserRecycler userListAdapter = (UserRecycler) userList.getAdapter();
|
||||
if (userListAdapter != null) {
|
||||
TwitterUser user = userListAdapter.getData().get(position);
|
||||
|
@ -178,7 +178,7 @@ public class UserProfile extends AppCompatActivity implements OnClickListener,
|
||||
break;
|
||||
case 1:
|
||||
mFavorites = new ProfileLoader(this);
|
||||
mFavorites.execute(userId, ProfileLoader.GET_FAVS,1L);
|
||||
mFavorites.execute(userId, ProfileLoader.GET_FAVORS, 1L);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -198,7 +198,7 @@ public class UserProfile extends AppCompatActivity implements OnClickListener,
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemClick(View v, ViewGroup parent, int position){
|
||||
public void onItemClick(ViewGroup parent, int position) {
|
||||
TimelineRecycler tweetAdapter;
|
||||
if(parent.getId() == R.id.ht_list) {
|
||||
tweetAdapter = (TimelineRecycler) homeList.getAdapter();
|
||||
@ -257,13 +257,13 @@ public class UserProfile extends AppCompatActivity implements OnClickListener,
|
||||
}
|
||||
|
||||
private void getProfileTweets() {
|
||||
new ProfileLoader(this).execute(userId, ProfileLoader.LOAD_DB, 1L);
|
||||
new ProfileLoader(this).execute(userId, ProfileLoader.LOAD_DB);
|
||||
mProfile = new ProfileLoader(this);
|
||||
mTweets = new ProfileLoader(this);
|
||||
mFavorites = new ProfileLoader(this);
|
||||
mProfile.execute(userId, ProfileLoader.GET_INFORMATION,1L);
|
||||
mProfile.execute(userId, ProfileLoader.GET_INF);
|
||||
mTweets.execute(userId, ProfileLoader.GET_TWEETS,1L);
|
||||
mFavorites.execute(userId, ProfileLoader.GET_FAVS,1L);
|
||||
mFavorites.execute(userId, ProfileLoader.GET_FAVORS, 1L);
|
||||
}
|
||||
|
||||
private void getConnection(int mode) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user