mirror of
https://github.com/nuclearfog/Shitter.git
synced 2025-01-31 19:34:55 +01:00
Base function finished
This commit is contained in:
parent
a7023e8905
commit
79667fbf41
@ -31,6 +31,11 @@ import org.nuclearfog.twidda.window.TweetDetail;
|
||||
import org.nuclearfog.twidda.window.TweetPopup;
|
||||
import org.nuclearfog.twidda.window.TwitterSearch;
|
||||
|
||||
/**
|
||||
* MainPage of the App
|
||||
* @see RegisterAccount Registing App in Twitter
|
||||
* @see MainPage show Home Window
|
||||
*/
|
||||
public class MainActivity extends AppCompatActivity implements AdapterView.OnItemClickListener,
|
||||
SwipeRefreshLayout.OnRefreshListener, TabHost.OnTabChangeListener
|
||||
{
|
||||
|
@ -15,7 +15,7 @@ import java.util.List;
|
||||
import twitter4j.Twitter;
|
||||
import twitter4j.User;
|
||||
|
||||
public class Following extends AsyncTask <Long, Void, Void> {
|
||||
public class FollowStatus extends AsyncTask <Long, Void, Void> {
|
||||
|
||||
private Context context;
|
||||
private Twitter twitter;
|
||||
@ -23,7 +23,7 @@ public class Following extends AsyncTask <Long, Void, Void> {
|
||||
private ListView followList;
|
||||
private SwipeRefreshLayout followReload;
|
||||
|
||||
public Following(Context context) {
|
||||
public FollowStatus(Context context) {
|
||||
this.context=context;
|
||||
}
|
||||
|
||||
@ -35,7 +35,7 @@ public class Following extends AsyncTask <Long, Void, Void> {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param data [0] mode Following/Follower , [1] UserID
|
||||
* @param data [0] mode FollowStatus/Follower , [1] UserID
|
||||
*/
|
||||
@Override
|
||||
protected Void doInBackground(Long... data) {
|
@ -8,7 +8,6 @@ import android.widget.ImageView;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
|
||||
|
||||
public class ImageDownloader extends AsyncTask<String, Void, Bitmap>
|
||||
{
|
||||
private ImageView imgView;
|
||||
|
@ -4,7 +4,7 @@ import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.AsyncTask;
|
||||
import android.support.v4.widget.SwipeRefreshLayout;
|
||||
import android.view.MenuItem;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ListView;
|
||||
@ -16,6 +16,8 @@ import org.nuclearfog.twidda.database.TweetDatabase;
|
||||
import org.nuclearfog.twidda.viewadapter.TimelineAdapter;
|
||||
import org.nuclearfog.twidda.window.UserProfile;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import twitter4j.Paging;
|
||||
import twitter4j.Twitter;
|
||||
import twitter4j.User;
|
||||
@ -28,6 +30,7 @@ public class ProfileAction extends AsyncTask<Long,Void,Long>
|
||||
public static final long GET_FAVS = 0x3;
|
||||
public static final long ACTION_MUTE = 0x4;
|
||||
private static final long FAILURE = 0x6;
|
||||
|
||||
private String screenName, username, description, location, follower, following;
|
||||
private TextView txtUser,txtScrName,txtBio,txtLocation,txtLink,txtFollowing,txtFollower;
|
||||
private ImageView profile, banner, linkIcon, locationIcon;
|
||||
@ -36,29 +39,18 @@ public class ProfileAction extends AsyncTask<Long,Void,Long>
|
||||
private String imageLink, bannerLink, link;
|
||||
private TimelineAdapter homeTl, homeFav;
|
||||
private Context context;
|
||||
private MenuItem item;
|
||||
private Toolbar tool;
|
||||
private boolean imgEnabled = false;
|
||||
private boolean isFollowing = false;
|
||||
private boolean isFollowed = false;
|
||||
private boolean muted = false;
|
||||
private boolean isHome = false;
|
||||
private int load;
|
||||
private long homeUserID;
|
||||
|
||||
/**
|
||||
* @param context Activity's Context
|
||||
*/
|
||||
public ProfileAction(Context context) {
|
||||
public ProfileAction(Context context, Toolbar tool) {
|
||||
this.context=context;
|
||||
init();
|
||||
}
|
||||
|
||||
public ProfileAction(Context context, MenuItem item) {
|
||||
this.context=context;
|
||||
this.item = item;
|
||||
init();
|
||||
}
|
||||
|
||||
private void init(){
|
||||
this.tool = tool;
|
||||
SharedPreferences settings = context.getSharedPreferences("settings", 0);
|
||||
imgEnabled = settings.getBoolean("image_load",false);
|
||||
load = settings.getInt("preload", 10);
|
||||
@ -86,23 +78,30 @@ public class ProfileAction extends AsyncTask<Long,Void,Long>
|
||||
|
||||
/**
|
||||
* @param args [0] Twitter User ID
|
||||
* @see #GET_INFORMATION
|
||||
* @see #ACTION_FOLLOW
|
||||
* @see #GET_TWEETS
|
||||
* @see #GET_FAVS
|
||||
* @see #ACTION_MUTE
|
||||
*/
|
||||
@Override
|
||||
protected Long doInBackground(Long... args) {
|
||||
long userId = args[0];
|
||||
final long MODE = args[1];
|
||||
isHome = userId == homeUserID;
|
||||
TwitterResource mTwitter = TwitterResource.getInstance(context);
|
||||
Twitter twitter = mTwitter.getTwitter();
|
||||
|
||||
Paging p = new Paging();
|
||||
p.setCount(load);
|
||||
try {
|
||||
if(homeUserID != userId) {
|
||||
if(!isHome)
|
||||
{
|
||||
isFollowing = twitter.showFriendship(homeUserID,userId).isSourceFollowingTarget();
|
||||
isFollowed = twitter.showFriendship(homeUserID,userId).isTargetFollowingSource();
|
||||
muted = twitter.showFriendship(homeUserID,userId).isSourceMutingTarget();
|
||||
}
|
||||
if(MODE == GET_INFORMATION) {
|
||||
if(MODE == GET_INFORMATION)
|
||||
{
|
||||
User user = twitter.showUser(userId);
|
||||
screenName = '@'+ user.getScreenName();
|
||||
username = user.getName();
|
||||
@ -114,15 +113,20 @@ public class ProfileAction extends AsyncTask<Long,Void,Long>
|
||||
imageLink = user.getProfileImageURL();
|
||||
bannerLink = user.getProfileBannerURL();
|
||||
}
|
||||
else if(MODE == GET_TWEETS) {
|
||||
TweetDatabase hTweets = new TweetDatabase(twitter.getUserTimeline(userId,p), context,TweetDatabase.USER_TL,userId);
|
||||
else if(MODE == GET_TWEETS)
|
||||
{
|
||||
List<twitter4j.Status> tweets = twitter.getUserTimeline(userId,p);
|
||||
TweetDatabase hTweets = new TweetDatabase(tweets,context,TweetDatabase.USER_TL,userId);
|
||||
homeTl = new TimelineAdapter(context,hTweets);
|
||||
}
|
||||
else if(MODE == GET_FAVS) {
|
||||
TweetDatabase fTweets = new TweetDatabase(twitter.getFavorites(userId,p), context,TweetDatabase.FAV_TL,userId);
|
||||
else if(MODE == GET_FAVS)
|
||||
{
|
||||
List<twitter4j.Status> favorits = twitter.getFavorites(userId,p);
|
||||
TweetDatabase fTweets = new TweetDatabase(favorits,context,TweetDatabase.FAV_TL,userId);
|
||||
homeFav = new TimelineAdapter(context,fTweets);
|
||||
}
|
||||
else if(MODE == ACTION_FOLLOW) {
|
||||
else if(MODE == ACTION_FOLLOW)
|
||||
{
|
||||
if(isFollowing) {
|
||||
twitter.destroyFriendship(userId);
|
||||
isFollowing = false;
|
||||
@ -131,7 +135,8 @@ public class ProfileAction extends AsyncTask<Long,Void,Long>
|
||||
isFollowing = true;
|
||||
}
|
||||
}
|
||||
else if(MODE == ACTION_MUTE) {
|
||||
else if(MODE == ACTION_MUTE)
|
||||
{
|
||||
if(muted) {
|
||||
twitter.destroyMute(userId);
|
||||
muted = false;
|
||||
@ -149,7 +154,8 @@ public class ProfileAction extends AsyncTask<Long,Void,Long>
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Long mode) {
|
||||
if(mode == GET_INFORMATION) {
|
||||
if(mode == GET_INFORMATION)
|
||||
{
|
||||
ImageDownloader profileImg, bannerImg;
|
||||
txtUser.setText(username);
|
||||
txtScrName.setText(screenName);
|
||||
@ -172,27 +178,31 @@ public class ProfileAction extends AsyncTask<Long,Void,Long>
|
||||
} else {
|
||||
profile.setImageResource(R.mipmap.pb);
|
||||
}
|
||||
} else if(mode == GET_TWEETS) {
|
||||
}
|
||||
else if(mode == GET_TWEETS)
|
||||
{
|
||||
profileTweets.setAdapter(homeTl);
|
||||
tweetsReload.setRefreshing(false);
|
||||
|
||||
} else if(mode == GET_FAVS) {
|
||||
}
|
||||
else if(mode == GET_FAVS)
|
||||
{
|
||||
profileFavorits.setAdapter(homeFav);
|
||||
favoritsReload.setRefreshing(false);
|
||||
|
||||
} else if(mode == FAILURE) {
|
||||
}
|
||||
else if(mode == FAILURE)
|
||||
{
|
||||
Toast.makeText(context,"Fehler beim Laden des Profils",Toast.LENGTH_LONG).show();
|
||||
} else if(mode == ACTION_FOLLOW) {
|
||||
}
|
||||
if(!isHome) { //Set Icons if it isn't the home profile
|
||||
if(isFollowing) {
|
||||
item.setIcon(R.drawable.follow_active);
|
||||
tool.getMenu().getItem(1).setIcon(R.drawable.follow_active);
|
||||
} else {
|
||||
item.setIcon(R.drawable.follow);
|
||||
tool.getMenu().getItem(1).setIcon(R.drawable.follow);
|
||||
}
|
||||
} else if(mode == ACTION_MUTE) {
|
||||
if(muted) {
|
||||
item.setIcon(R.drawable.block_active);
|
||||
tool.getMenu().getItem(2).setIcon(R.drawable.block_active);
|
||||
} else {
|
||||
item.setIcon(R.drawable.block);
|
||||
tool.getMenu().getItem(2).setIcon(R.drawable.block);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ 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;
|
||||
@ -26,6 +27,7 @@ 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;
|
||||
|
@ -16,6 +16,10 @@ import android.widget.Switch;
|
||||
import org.nuclearfog.twidda.R;
|
||||
import org.nuclearfog.twidda.database.ColorPreferences;
|
||||
|
||||
/**
|
||||
* App Settings Page
|
||||
* @see ColorPreferences
|
||||
*/
|
||||
public class AppSettings extends AppCompatActivity implements View.OnClickListener,
|
||||
CompoundButton.OnCheckedChangeListener {
|
||||
|
||||
|
@ -10,11 +10,15 @@ import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ListView;
|
||||
|
||||
import org.nuclearfog.twidda.backend.Following;
|
||||
import org.nuclearfog.twidda.backend.FollowStatus;
|
||||
import org.nuclearfog.twidda.database.UserDatabase;
|
||||
import org.nuclearfog.twidda.R;
|
||||
import org.nuclearfog.twidda.viewadapter.UserAdapter;
|
||||
|
||||
/**
|
||||
* Get Follow Connections from an User
|
||||
* @see FollowStatus
|
||||
*/
|
||||
public class Follower extends AppCompatActivity implements AdapterView.OnItemClickListener,
|
||||
SwipeRefreshLayout.OnRefreshListener {
|
||||
|
||||
@ -64,7 +68,7 @@ public class Follower extends AppCompatActivity implements AdapterView.OnItemCli
|
||||
|
||||
@Override
|
||||
public void onRefresh() {
|
||||
Following follow = new Following(Follower.this);
|
||||
FollowStatus follow = new FollowStatus(Follower.this);
|
||||
follow.execute(mode, userID);
|
||||
}
|
||||
|
||||
|
@ -16,6 +16,10 @@ import org.nuclearfog.twidda.database.TweetDatabase;
|
||||
import org.nuclearfog.twidda.R;
|
||||
import org.nuclearfog.twidda.viewadapter.TimelineAdapter;
|
||||
|
||||
/**
|
||||
* Detailed Tweet Window
|
||||
* @see ShowStatus
|
||||
*/
|
||||
public class TweetDetail extends AppCompatActivity implements View.OnClickListener, AdapterView.OnItemClickListener {
|
||||
|
||||
private ListView answer_list;
|
||||
|
@ -11,6 +11,10 @@ import org.nuclearfog.twidda.backend.SendStatus;
|
||||
import org.nuclearfog.twidda.R;
|
||||
import org.nuclearfog.twidda.database.ColorPreferences;
|
||||
|
||||
/**
|
||||
* Tweet Window
|
||||
* @see SendStatus
|
||||
*/
|
||||
public class TweetPopup extends AppCompatActivity implements View.OnClickListener {
|
||||
|
||||
private EditText tweetfield;
|
||||
|
@ -19,12 +19,16 @@ import org.nuclearfog.twidda.database.UserDatabase;
|
||||
import org.nuclearfog.twidda.viewadapter.TimelineAdapter;
|
||||
import org.nuclearfog.twidda.viewadapter.UserAdapter;
|
||||
|
||||
/**
|
||||
* Search Tweets and Users
|
||||
* @see Search
|
||||
*/
|
||||
public class TwitterSearch extends AppCompatActivity implements AdapterView.OnItemClickListener,
|
||||
SwipeRefreshLayout.OnRefreshListener, TabHost.OnTabChangeListener {
|
||||
|
||||
private String search;
|
||||
private ListView tweetSearch, userSearch;
|
||||
private SwipeRefreshLayout tweetReload,userReload;
|
||||
private String search;
|
||||
private String currentTab = "search_result";
|
||||
|
||||
@Override
|
||||
|
@ -13,17 +13,22 @@ import android.widget.ListView;
|
||||
import android.widget.TabHost;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.nuclearfog.twidda.R;
|
||||
import org.nuclearfog.twidda.database.TweetDatabase;
|
||||
import org.nuclearfog.twidda.backend.ProfileAction;
|
||||
import org.nuclearfog.twidda.R;
|
||||
import org.nuclearfog.twidda.viewadapter.TimelineAdapter;
|
||||
|
||||
/**
|
||||
* User Profile Class uses AsyncTask
|
||||
* @see ProfileAction
|
||||
*/
|
||||
public class UserProfile extends AppCompatActivity implements View.OnClickListener,
|
||||
AdapterView.OnItemClickListener, SwipeRefreshLayout.OnRefreshListener, TabHost.OnTabChangeListener {
|
||||
|
||||
private SwipeRefreshLayout homeReload, favoriteReload;
|
||||
private ListView homeTweets, homeFavorits;
|
||||
private TextView txtFollowing, txtFollower;
|
||||
private Toolbar tool;
|
||||
private long userId;
|
||||
private boolean home;
|
||||
private String currentTab = "tweets";
|
||||
@ -32,7 +37,7 @@ public class UserProfile extends AppCompatActivity implements View.OnClickListen
|
||||
protected void onCreate(Bundle savedInstance) {
|
||||
super.onCreate(savedInstance);
|
||||
setContentView(R.layout.profile);
|
||||
Toolbar tool = (Toolbar) findViewById(R.id.profile_toolbar);
|
||||
tool = (Toolbar) findViewById(R.id.profile_toolbar);
|
||||
setSupportActionBar(tool);
|
||||
getSupportActionBar().setDisplayShowTitleEnabled(false);
|
||||
userId = getIntent().getExtras().getLong("userID");
|
||||
@ -44,7 +49,6 @@ public class UserProfile extends AppCompatActivity implements View.OnClickListen
|
||||
homeReload = (SwipeRefreshLayout) findViewById(R.id.hometweets);
|
||||
favoriteReload = (SwipeRefreshLayout) findViewById(R.id.homefavorits);
|
||||
TabHost mTab = (TabHost)findViewById(R.id.profile_tab);
|
||||
|
||||
mTab.setup();
|
||||
// Tab #1
|
||||
TabHost.TabSpec tab1 = mTab.newTabSpec("tweets");
|
||||
@ -88,7 +92,7 @@ public class UserProfile extends AppCompatActivity implements View.OnClickListen
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
Intent intent;
|
||||
ProfileAction action = new ProfileAction(this, item);
|
||||
ProfileAction action = new ProfileAction(this, tool);
|
||||
switch(item.getItemId()) {
|
||||
case R.id.profile_tweet:
|
||||
intent = new Intent(this, TweetPopup.class);
|
||||
@ -158,7 +162,7 @@ public class UserProfile extends AppCompatActivity implements View.OnClickListen
|
||||
|
||||
@Override
|
||||
public void onRefresh() {
|
||||
ProfileAction tweets = new ProfileAction(this);
|
||||
ProfileAction tweets = new ProfileAction(this, tool);
|
||||
switch(currentTab) {
|
||||
case "tweets":
|
||||
tweets.execute(userId, ProfileAction.GET_TWEETS);
|
||||
@ -191,7 +195,7 @@ public class UserProfile extends AppCompatActivity implements View.OnClickListen
|
||||
}
|
||||
|
||||
private void initElements() {
|
||||
ProfileAction profile = new ProfileAction(this);
|
||||
ProfileAction profile = new ProfileAction(this, tool);
|
||||
profile.execute(userId, ProfileAction.GET_INFORMATION);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user