renamed class, added comments

This commit is contained in:
nuclearfog 2020-09-07 16:30:42 +02:00
parent 610f365f56
commit d4a394f4ad
No known key found for this signature in database
GPG Key ID: ED35E22099354A64
28 changed files with 282 additions and 90 deletions

View File

@ -70,7 +70,7 @@
android:theme="@style/AppTheme" />
<activity
android:name=".activity.TweetDetail"
android:name=".activity.TweetActivity"
android:screenOrientation="portrait"
android:theme="@style/AppTheme" />
@ -80,7 +80,7 @@
android:theme="@style/AppTheme" />
<activity
android:name=".activity.LoginPage"
android:name=".activity.LoginActivity"
android:screenOrientation="portrait"
android:theme="@style/AppTheme" />

View File

@ -17,7 +17,9 @@ import org.nuclearfog.twidda.adapter.FragmentAdapter;
import org.nuclearfog.twidda.backend.helper.FontTool;
import org.nuclearfog.twidda.database.GlobalSettings;
/**
* Activity for the direct message page of the current user
*/
public class DirectMessage extends AppCompatActivity {
@Override

View File

@ -17,7 +17,9 @@ import org.nuclearfog.twidda.adapter.FragmentAdapter;
import org.nuclearfog.twidda.backend.helper.FontTool;
import org.nuclearfog.twidda.database.GlobalSettings;
/**
* Activity to show an user list, members and tweets
*/
public class ListDetail extends AppCompatActivity implements OnTabSelectedListener {
public static final String KEY_LISTDETAIL_ID = "list-id";

View File

@ -30,9 +30,14 @@ import static android.os.AsyncTask.Status.RUNNING;
import static android.widget.Toast.LENGTH_LONG;
import static android.widget.Toast.LENGTH_SHORT;
public class LoginPage extends AppCompatActivity implements OnClickListener {
/**
* Login Activity of the App
* called from {@link MainActivity} when this app isn't logged in to twitter
*/
public class LoginActivity extends AppCompatActivity implements OnClickListener {
private Registration registerAsync;
private Button linkButton, loginButton;
private EditText pinInput;
private View root;
@ -126,7 +131,11 @@ public class LoginPage extends AppCompatActivity implements OnClickListener {
}
}
/**
* Called when a twitter login link was created
*
* @param link Link to twitter login page
*/
public void connect(String link) {
Intent loginIntent = new Intent(ACTION_VIEW, Uri.parse(link));
if (loginIntent.resolveActivity(getPackageManager()) != null) {
@ -136,12 +145,19 @@ public class LoginPage extends AppCompatActivity implements OnClickListener {
}
}
/**
* Called when the app is registered successfully to twitter
*/
public void onSuccess() {
setResult(Activity.RESULT_OK);
finish();
}
/**
* called when an error occurs while login
*
* @param error Twitter exception
*/
public void onError(EngineException error) {
ErrorHandler.handleFailure(this, error);
}

View File

@ -32,7 +32,7 @@ import static org.nuclearfog.twidda.activity.SearchPage.KEY_SEARCH_QUERY;
import static org.nuclearfog.twidda.activity.UserProfile.KEY_PROFILE_ID;
/**
* Main Activity
* Main Activity of the App
*/
public class MainActivity extends AppCompatActivity implements OnTabSelectedListener, OnQueryTextListener {
@ -50,7 +50,7 @@ public class MainActivity extends AppCompatActivity implements OnTabSelectedList
static {
// Enable vector drawable support
// Enable vector drawable support for API 16 to 21
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
}
@ -86,7 +86,7 @@ public class MainActivity extends AppCompatActivity implements OnTabSelectedList
protected void onStart() {
super.onStart();
if (!settings.getLogin()) {
Intent loginIntent = new Intent(this, LoginPage.class);
Intent loginIntent = new Intent(this, LoginActivity.class);
startActivityForResult(loginIntent, REQUEST_APP_LOGIN);
} else if (adapter.isEmpty()) {
adapter.setupForHomePage();

View File

@ -44,7 +44,9 @@ import static android.view.View.INVISIBLE;
import static android.view.View.VISIBLE;
import static androidx.recyclerview.widget.LinearLayoutManager.HORIZONTAL;
/**
* Media viewer activity for images and videos
*/
public class MediaViewer extends AppCompatActivity implements OnImageClickListener,
OnPreparedListener, OnInfoListener, OnErrorListener {
@ -52,17 +54,18 @@ public class MediaViewer extends AppCompatActivity implements OnImageClickListen
public static final String KEY_MEDIA_TYPE = "media_type";
/// Media Types
private static final int MEDIAVIEWER_NONE = 0;
public static final int MEDIAVIEWER_IMG_S = 1;
public static final int MEDIAVIEWER_IMAGE = 2;
public static final int MEDIAVIEWER_VIDEO = 3;
public static final int MEDIAVIEWER_ANGIF = 4;
private static final int MEDIAVIEWER_NONE = 0; // Not Initialized
public static final int MEDIAVIEWER_IMG_S = 1; // Image from Storage
public static final int MEDIAVIEWER_IMAGE = 2; // Image from Twitter
public static final int MEDIAVIEWER_VIDEO = 3; // Video from Twitter
public static final int MEDIAVIEWER_ANGIF = 4; // GIF from Twitter
private static final SimpleDateFormat formatter = new SimpleDateFormat("yyyy_MM_dd_HH_mm_ss", Locale.GERMANY);
private static final String[] REQ_WRITE_SD = {WRITE_EXTERNAL_STORAGE};
private static final int REQCODE_SD = 6;
private ImageLoader imageAsync;
private ProgressBar video_progress;
private ProgressBar image_progress;
private MediaController videoController;
@ -71,8 +74,8 @@ public class MediaViewer extends AppCompatActivity implements OnImageClickListen
private ImageAdapter adapter;
private VideoView videoView;
private ZoomView zoomImage;
private int type;
private int type;
private int videoPos = 0;
@ -214,12 +217,18 @@ public class MediaViewer extends AppCompatActivity implements OnImageClickListen
return false;
}
/**
* Called from {@link ImageLoader} when all images are downloaded successfully
*/
public void onSuccess() {
adapter.disableLoading();
}
/**
* Called from {@link ImageLoader} when an error occurs
*
* @param err Exception caught by {@link ImageLoader}
*/
public void onError(@Nullable EngineException err) {
if (err != null) {
ErrorHandler.handleFailure(getApplicationContext(), err);
@ -227,7 +236,11 @@ public class MediaViewer extends AppCompatActivity implements OnImageClickListen
finish();
}
/**
* set downloaded image into preview list
*
* @param image Image container
*/
public void setImage(ImageHolder image) {
if (adapter.isEmpty()) {
zoomImage.reset();
@ -237,7 +250,11 @@ public class MediaViewer extends AppCompatActivity implements OnImageClickListen
adapter.addLast(image);
}
/**
* called to save an image into storage
*
* @param image Image file
*/
private void storeImage(Bitmap image) {
String name = "shitter_" + formatter.format(new Date());
try {

View File

@ -41,7 +41,9 @@ import static org.nuclearfog.twidda.activity.MediaViewer.KEY_MEDIA_LINK;
import static org.nuclearfog.twidda.activity.MediaViewer.KEY_MEDIA_TYPE;
import static org.nuclearfog.twidda.activity.MediaViewer.MEDIAVIEWER_IMG_S;
/**
* Direct message popup activity
*/
public class MessagePopup extends AppCompatActivity implements OnClickListener, OnDismissListener {
public static final String KEY_DM_PREFIX = "dm_prefix";
@ -50,9 +52,11 @@ public class MessagePopup extends AppCompatActivity implements OnClickListener,
private static final int REQ_PERM_READ = 4;
private MessageUploader messageAsync;
private EditText receiver, message;
private ImageButton media;
private Dialog loadingCircle;
@Nullable
private String mediaPath;
@ -138,8 +142,9 @@ public class MessagePopup extends AppCompatActivity implements OnClickListener,
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
if (requestCode == REQ_PERM_READ && grantResults[0] == PERMISSION_GRANTED)
if (requestCode == REQ_PERM_READ && grantResults[0] == PERMISSION_GRANTED) {
getMedia();
}
}
@ -212,7 +217,10 @@ public class MessagePopup extends AppCompatActivity implements OnClickListener,
ErrorHandler.handleFailure(this, error);
}
/**
* access to storage to add an image to the direct message
* or ask for permission
*/
private void getMedia() {
boolean accessGranted = true;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {

View File

@ -49,7 +49,9 @@ import static android.view.Window.FEATURE_NO_TITLE;
import static android.widget.Toast.LENGTH_SHORT;
import static org.nuclearfog.twidda.activity.UserProfile.RETURN_PROFILE_CHANGED;
/**
* Activity for Twitter profile editor
*/
public class ProfileEditor extends AppCompatActivity implements OnClickListener, OnDismissListener {
private static final String[] PERM_READ = {READ_EXTERNAL_STORAGE};
@ -59,10 +61,12 @@ public class ProfileEditor extends AppCompatActivity implements OnClickListener,
private static final int REQ_PROFILE_BANNER = 5;
private ProfileUpdater editorAsync;
private ImageView profile_image, profile_banner;
private EditText name, link, loc, bio;
private Button add_banner_btn;
private Dialog loadingCircle;
private TwitterUser user;
private String profileLink, bannerLink;
@ -255,7 +259,11 @@ public class ProfileEditor extends AppCompatActivity implements OnClickListener,
}
}
/**
* Set current user's information
*
* @param user Current user
*/
public void setUser(TwitterUser user) {
String pbLink = user.getImageLink();
String bnLink = user.getBannerLink() + "/600x200";
@ -295,7 +303,11 @@ public class ProfileEditor extends AppCompatActivity implements OnClickListener,
}
}
/**
* Get images from storage or ask for permission
*
* @param request image type to load from storage
*/
private void getMedia(int request) {
boolean accessGranted = true;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {

View File

@ -61,8 +61,10 @@ import static org.nuclearfog.twidda.activity.UserDetail.USERLIST_RETWEETS;
import static org.nuclearfog.twidda.fragment.TweetFragment.INTENT_TWEET_REMOVED_ID;
import static org.nuclearfog.twidda.fragment.TweetFragment.RETURN_TWEET_CHANGED;
public class TweetDetail extends AppCompatActivity implements OnClickListener,
/**
* Tweet Activity for tweet and user informations
*/
public class TweetActivity extends AppCompatActivity implements OnClickListener,
OnLongClickListener, OnTagClickListener {
public static final String KEY_TWEET_ID = "tweetID";
@ -177,7 +179,7 @@ public class TweetDetail extends AppCompatActivity implements OnClickListener,
deleteDialog.setPositiveButton(R.string.confirm_yes, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
statusAsync = new TweetLoader(TweetDetail.this, Action.DELETE);
statusAsync = new TweetLoader(TweetActivity.this, Action.DELETE);
statusAsync.execute(tweet.getId());
}
});
@ -242,7 +244,7 @@ public class TweetDetail extends AppCompatActivity implements OnClickListener,
case R.id.answer_reference_detail:
if (tweet != null) {
Intent answerIntent = new Intent(getApplicationContext(), TweetDetail.class);
Intent answerIntent = new Intent(getApplicationContext(), TweetActivity.class);
answerIntent.putExtra(KEY_TWEET_ID, tweet.getReplyId());
answerIntent.putExtra(KEY_TWEET_NAME, tweet.getReplyName());
startActivity(answerIntent);
@ -324,7 +326,7 @@ public class TweetDetail extends AppCompatActivity implements OnClickListener,
if (LINK_PATTERN.matcher(shortLink).matches()) {
String name = shortLink.substring(20, shortLink.indexOf('/', 20));
long id = Long.parseLong(shortLink.substring(shortLink.lastIndexOf('/') + 1));
Intent intent = new Intent(this, TweetDetail.class);
Intent intent = new Intent(this, TweetActivity.class);
intent.putExtra(KEY_TWEET_ID, id);
intent.putExtra(KEY_TWEET_NAME, name);
startActivity(intent);

View File

@ -52,7 +52,9 @@ import static org.nuclearfog.twidda.activity.MediaViewer.KEY_MEDIA_TYPE;
import static org.nuclearfog.twidda.activity.MediaViewer.MEDIAVIEWER_IMG_S;
import static org.nuclearfog.twidda.activity.MediaViewer.MEDIAVIEWER_VIDEO;
/**
* Activity to create a tweet
*/
public class TweetPopup extends AppCompatActivity implements OnClickListener, LocationListener, OnDismissListener {
public static final String KEY_TWEETPOPUP_REPLYID = "tweet_replyID";
@ -340,6 +342,7 @@ public class TweetPopup extends AppCompatActivity implements OnClickListener, Lo
/**
* Show confirmation dialog if an error occurs while sending tweet
*
* @param tweet tweet to re-send
*/
public void onError(final TweetHolder tweet, EngineException error) {

View File

@ -13,7 +13,9 @@ import org.nuclearfog.twidda.adapter.FragmentAdapter;
import org.nuclearfog.twidda.backend.helper.FontTool;
import org.nuclearfog.twidda.database.GlobalSettings;
/**
* Activity to show user lists of a twitter user
*/
public class TwitterList extends AppCompatActivity {
public static final String KEY_USERLIST_OWNER_ID = "userlist-owner-id";

View File

@ -13,6 +13,9 @@ import org.nuclearfog.twidda.adapter.FragmentAdapter;
import org.nuclearfog.twidda.backend.helper.FontTool;
import org.nuclearfog.twidda.database.GlobalSettings;
/**
* Activity to show a list of twitter users
*/
public class UserDetail extends AppCompatActivity {
public static final String KEY_USERDETAIL_MODE = "userlist_mode";

View File

@ -56,9 +56,9 @@ import static org.nuclearfog.twidda.activity.MediaViewer.KEY_MEDIA_TYPE;
import static org.nuclearfog.twidda.activity.MediaViewer.MEDIAVIEWER_IMAGE;
import static org.nuclearfog.twidda.activity.MessagePopup.KEY_DM_PREFIX;
import static org.nuclearfog.twidda.activity.SearchPage.KEY_SEARCH_QUERY;
import static org.nuclearfog.twidda.activity.TweetDetail.KEY_TWEET_ID;
import static org.nuclearfog.twidda.activity.TweetDetail.KEY_TWEET_NAME;
import static org.nuclearfog.twidda.activity.TweetDetail.LINK_PATTERN;
import static org.nuclearfog.twidda.activity.TweetActivity.KEY_TWEET_ID;
import static org.nuclearfog.twidda.activity.TweetActivity.KEY_TWEET_NAME;
import static org.nuclearfog.twidda.activity.TweetActivity.LINK_PATTERN;
import static org.nuclearfog.twidda.activity.TweetPopup.KEY_TWEETPOPUP_TEXT;
import static org.nuclearfog.twidda.activity.TwitterList.KEY_USERLIST_OWNER_ID;
import static org.nuclearfog.twidda.activity.UserDetail.KEY_USERDETAIL_ID;
@ -379,7 +379,7 @@ public class UserProfile extends AppCompatActivity implements OnClickListener,
if (LINK_PATTERN.matcher(shortLink).matches()) {
String name = shortLink.substring(20, shortLink.indexOf('/', 20));
long id = Long.parseLong(shortLink.substring(shortLink.lastIndexOf('/') + 1));
Intent intent = new Intent(this, TweetDetail.class);
Intent intent = new Intent(this, TweetActivity.class);
intent.putExtra(KEY_TWEET_ID, id);
intent.putExtra(KEY_TWEET_NAME, name);
startActivity(intent);

View File

@ -35,6 +35,9 @@ import static org.nuclearfog.twidda.fragment.UserFragment.USER_FRAG_RETWEET;
import static org.nuclearfog.twidda.fragment.UserFragment.USER_FRAG_SEARCH;
import static org.nuclearfog.twidda.fragment.UserFragment.USER_FRAG_SUBSCR;
/**
* Fragment adapter for ViewPager
*/
public class FragmentAdapter extends FragmentStatePagerAdapter {
private Fragment[] fragments;
@ -62,18 +65,26 @@ public class FragmentAdapter extends FragmentStatePagerAdapter {
return fragments.length;
}
/**
* Check if adapter is empty
*
* @return true if adapter does not contain fragments
*/
public boolean isEmpty() {
return fragments.length == 0;
}
/**
* Clear all fragments
*/
public void clear() {
fragments = new Fragment[0];
notifyDataSetChanged();
}
/**
* setup adapter for the home activity
*/
public void setupForHomePage() {
Bundle home_tl = new Bundle();
Bundle ment_tl = new Bundle();
@ -88,7 +99,11 @@ public class FragmentAdapter extends FragmentStatePagerAdapter {
notifyDataSetChanged();
}
/**
* setup adapter for viewing user tweets and favs
*
* @param userId ID of the user
*/
public void setupProfilePage(long userId) {
Bundle usr_tweet = new Bundle();
Bundle usr_favor = new Bundle();
@ -104,7 +119,11 @@ public class FragmentAdapter extends FragmentStatePagerAdapter {
notifyDataSetChanged();
}
/**
* setup adapter for viewing user tweets and favs
*
* @param username screen name of the user
*/
public void setupProfilePage(String username) {
Bundle usr_tweet = new Bundle();
Bundle usr_favor = new Bundle();
@ -120,7 +139,11 @@ public class FragmentAdapter extends FragmentStatePagerAdapter {
notifyDataSetChanged();
}
/**
* setup adapter for search for tweet and user search
*
* @param search Search string
*/
public void setupSearchPage(String search) {
Bundle tweetSearch = new Bundle();
Bundle userSearch = new Bundle();
@ -136,7 +159,12 @@ public class FragmentAdapter extends FragmentStatePagerAdapter {
notifyDataSetChanged();
}
/**
* setup adapter for tweet page to show replies of a tweet
*
* @param tweetId ID of the tweet
* @param replyName screen name of the author
*/
public void setupTweetPage(long tweetId, String replyName) {
Bundle param = new Bundle();
param.putInt(KEY_FRAG_TWEET_MODE, TWEET_FRAG_ANSWER);
@ -148,7 +176,11 @@ public class FragmentAdapter extends FragmentStatePagerAdapter {
notifyDataSetChanged();
}
/**
* setup adapter for a list of friends
*
* @param userId ID of the user
*/
public void setupFriendsPage(long userId) {
Bundle param = new Bundle();
param.putLong(KEY_FRAG_USER_ID, userId);
@ -159,7 +191,11 @@ public class FragmentAdapter extends FragmentStatePagerAdapter {
notifyDataSetChanged();
}
/**
* setup adapter for a list of follower
*
* @param userId ID of the user
*/
public void setupFollowerPage(long userId) {
Bundle param = new Bundle();
param.putLong(KEY_FRAG_USER_ID, userId);
@ -170,14 +206,20 @@ public class FragmentAdapter extends FragmentStatePagerAdapter {
notifyDataSetChanged();
}
/**
* setup adapter for a list of direct messages
*/
public void setupMessagePage() {
fragments = new Fragment[1];
fragments[0] = new MessageFragment();
notifyDataSetChanged();
}
/**
* setup adapter for a list of users which retweets a tweet
*
* @param tweetId ID if the tweet
*/
public void setupRetweeterPage(long tweetId) {
Bundle param = new Bundle();
param.putLong(KEY_FRAG_USER_ID, tweetId);
@ -188,17 +230,25 @@ public class FragmentAdapter extends FragmentStatePagerAdapter {
notifyDataSetChanged();
}
public void setupListPage(long listId) {
/**
* setup adapter for a list of user lists created by an user
*
* @param userId ID of the user
*/
public void setupListPage(long userId) {
Bundle param = new Bundle();
param.putLong(KEY_FRAG_LIST_OWNER_ID, listId);
param.putLong(KEY_FRAG_LIST_OWNER_ID, userId);
fragments = new Fragment[1];
fragments[0] = new ListFragment();
fragments[0].setArguments(param);
notifyDataSetChanged();
}
/**
* setup adapter for a list of user lists created by an user
*
* @param ownerName screen name of the owner
*/
public void setupListPage(String ownerName) {
Bundle param = new Bundle();
param.putString(KEY_FRAG_LIST_OWNER_NAME, ownerName);
@ -208,7 +258,11 @@ public class FragmentAdapter extends FragmentStatePagerAdapter {
notifyDataSetChanged();
}
/**
* setup adapter for a list of users subscribing an user list
*
* @param listId ID of an user list
*/
public void setupSubscriberPage(long listId) {
Bundle param = new Bundle();
param.putLong(KEY_FRAG_USER_ID, listId);
@ -219,7 +273,11 @@ public class FragmentAdapter extends FragmentStatePagerAdapter {
notifyDataSetChanged();
}
/**
* setup adapter for a page of tweets and users in an user list
*
* @param listId ID of an user list
*/
public void setupListContentPage(long listId) {
Bundle tweetParam = new Bundle();
Bundle userParam = new Bundle();

View File

@ -22,7 +22,9 @@ import java.util.List;
import static android.view.View.VISIBLE;
import static androidx.recyclerview.widget.RecyclerView.NO_POSITION;
/**
* Adapter class for image previews
*/
public class ImageAdapter extends Adapter<ViewHolder> {
private static final int PICTURE = 0;
@ -34,7 +36,11 @@ public class ImageAdapter extends Adapter<ViewHolder> {
private boolean loading = false;
private boolean saveImg = true;
/**
* Create an adapter for image previews
*
* @param itemClickListener Click listener for images
*/
public ImageAdapter(OnImageClickListener itemClickListener) {
this.itemClickListener = itemClickListener;
images = new LinkedList<>();
@ -58,12 +64,18 @@ public class ImageAdapter extends Adapter<ViewHolder> {
notifyItemRemoved(circlePos);
}
/**
* disable save button on images
*/
public void disableSaveButton() {
saveImg = false;
}
/**
* check if image adapter is empty
*
* @return true if there isn't any image
*/
public boolean isEmpty() {
return images.isEmpty();
}

View File

@ -30,6 +30,11 @@ import static android.view.View.VISIBLE;
import static androidx.recyclerview.widget.RecyclerView.NO_POSITION;
import static org.nuclearfog.twidda.backend.helper.TimeString.getTimeString;
/**
* Adapter class for user lists
*
* @see org.nuclearfog.twidda.fragment.ListFragment
*/
public class ListAdapter extends Adapter<ListAdapter.ListHolder> {
private ListClickListener listener;
@ -199,7 +204,9 @@ public class ListAdapter extends Adapter<ListAdapter.ListHolder> {
}
}
/**
* Listener for an item
*/
public interface ListClickListener {
enum Action {
@ -210,6 +217,12 @@ public class ListAdapter extends Adapter<ListAdapter.ListHolder> {
DELETE
}
/**
* called when an item is clicked
*
* @param listItem Item data and information
* @param action which button was clicked
*/
void onClick(TwitterList listItem, Action action);
}
}

View File

@ -31,6 +31,11 @@ import java.util.List;
import static androidx.recyclerview.widget.RecyclerView.NO_POSITION;
import static org.nuclearfog.twidda.backend.helper.TimeString.getTimeString;
/**
* Adapter class for direct messages list
*
* @see org.nuclearfog.twidda.fragment.MessageFragment
*/
public class MessageAdapter extends Adapter<MessageAdapter.MessageHolder> {
private OnItemSelected itemClickListener;
@ -45,7 +50,11 @@ public class MessageAdapter extends Adapter<MessageAdapter.MessageHolder> {
messages = new ArrayList<>();
}
/**
* replace all messages from list
*
* @param messageList new message list
*/
@MainThread
public void replaceAll(@NonNull List<Message> messageList) {
messages.clear();
@ -53,7 +62,11 @@ public class MessageAdapter extends Adapter<MessageAdapter.MessageHolder> {
notifyDataSetChanged();
}
/**
* Remove a single item from list if found
*
* @param id message ID
*/
@MainThread
public void remove(long id) {
int pos = -1;

View File

@ -25,6 +25,11 @@ import static android.view.View.GONE;
import static android.view.View.VISIBLE;
import static androidx.recyclerview.widget.RecyclerView.NO_POSITION;
/**
* Adapter class for Trend list
*
* @see org.nuclearfog.twidda.fragment.TrendFragment
*/
public class TrendAdapter extends Adapter<TrendAdapter.ItemHolder> {
private TrendClickListener itemClickListener;
@ -41,7 +46,11 @@ public class TrendAdapter extends Adapter<TrendAdapter.ItemHolder> {
trends = new ArrayList<>();
}
/**
* replace data from list
*
* @param trendList list of trends
*/
@MainThread
public void setData(@NonNull List<TwitterTrend> trendList) {
trends.clear();
@ -49,14 +58,20 @@ public class TrendAdapter extends Adapter<TrendAdapter.ItemHolder> {
notifyDataSetChanged();
}
/**
* clear all data from adapter
*/
@MainThread
public void clear() {
trends.clear();
notifyDataSetChanged();
}
/**
* check if adapter is empty
*
* @return true if adapter is empty
*/
public boolean isEmpty() {
return trends.isEmpty();
}

View File

@ -290,7 +290,7 @@ public class TweetAdapter extends Adapter<ViewHolder> {
}
class PlaceHolder extends ViewHolder {
static class PlaceHolder extends ViewHolder {
final Button loadBtn;
final ProgressBar loadCircle;

View File

@ -196,7 +196,7 @@ public class UserAdapter extends Adapter<ViewHolder> {
}
class ItemHolder extends ViewHolder {
static class ItemHolder extends ViewHolder {
final ImageView profileImg;
final TextView username, screenname;
@ -208,7 +208,7 @@ public class UserAdapter extends Adapter<ViewHolder> {
}
}
class PlaceHolder extends ViewHolder {
static class PlaceHolder extends ViewHolder {
final ProgressBar loadCircle;
final Button loadBtn;

View File

@ -11,7 +11,7 @@ import androidx.annotation.Nullable;
import org.nuclearfog.twidda.activity.DirectMessage;
import org.nuclearfog.twidda.activity.MainActivity;
import org.nuclearfog.twidda.activity.SearchPage;
import org.nuclearfog.twidda.activity.TweetDetail;
import org.nuclearfog.twidda.activity.TweetActivity;
import org.nuclearfog.twidda.activity.TweetPopup;
import org.nuclearfog.twidda.activity.TwitterList;
import org.nuclearfog.twidda.activity.UserProfile;
@ -20,8 +20,8 @@ import java.lang.ref.WeakReference;
import java.util.regex.Pattern;
import static org.nuclearfog.twidda.activity.SearchPage.KEY_SEARCH_QUERY;
import static org.nuclearfog.twidda.activity.TweetDetail.KEY_TWEET_ID;
import static org.nuclearfog.twidda.activity.TweetDetail.KEY_TWEET_NAME;
import static org.nuclearfog.twidda.activity.TweetActivity.KEY_TWEET_ID;
import static org.nuclearfog.twidda.activity.TweetActivity.KEY_TWEET_NAME;
import static org.nuclearfog.twidda.activity.TweetPopup.KEY_TWEETPOPUP_TEXT;
import static org.nuclearfog.twidda.activity.TwitterList.KEY_USERLIST_OWNER_NAME;
import static org.nuclearfog.twidda.activity.UserProfile.KEY_PROFILE_NAME;
@ -105,7 +105,7 @@ public class LinkContentLoader extends AsyncTask<Uri, Integer, LinkContentLoader
long tweetId = Long.parseLong(path.substring(path.lastIndexOf('/') + 1));
data.putLong(KEY_TWEET_ID, tweetId);
data.putString(KEY_TWEET_NAME, username);
dataHolder = new DataHolder(data, TweetDetail.class);
dataHolder = new DataHolder(data, TweetActivity.class);
} else if (LIST_PATH.matcher(path).matches()) {
String username = '@' + path.substring(0, path.indexOf('/'));
data.putString(KEY_USERLIST_OWNER_NAME, username);

View File

@ -4,7 +4,7 @@ import android.os.AsyncTask;
import androidx.annotation.Nullable;
import org.nuclearfog.twidda.activity.LoginPage;
import org.nuclearfog.twidda.activity.LoginActivity;
import org.nuclearfog.twidda.backend.engine.EngineException;
import org.nuclearfog.twidda.backend.engine.TwitterEngine;
@ -12,21 +12,22 @@ import java.lang.ref.WeakReference;
/**
* Background task to connect to twitter and initialize keys
* @see LoginPage
*
* @see LoginActivity
*/
public class Registration extends AsyncTask<String, Void, String> {
@Nullable
private EngineException twException;
private WeakReference<LoginPage> callback;
private WeakReference<LoginActivity> callback;
private TwitterEngine mTwitter;
/**
* Login to twitter with PIN
*
* @param callback Activity Context
* @param callback Activity Context
*/
public Registration(LoginPage callback) {
public Registration(LoginActivity callback) {
this.callback = new WeakReference<>(callback);
mTwitter = TwitterEngine.getInstance(callback);
}

View File

@ -4,7 +4,7 @@ import android.os.AsyncTask;
import androidx.annotation.Nullable;
import org.nuclearfog.twidda.activity.TweetDetail;
import org.nuclearfog.twidda.activity.TweetActivity;
import org.nuclearfog.twidda.backend.engine.EngineException;
import org.nuclearfog.twidda.backend.engine.TwitterEngine;
import org.nuclearfog.twidda.backend.items.Tweet;
@ -15,7 +15,8 @@ import java.lang.ref.WeakReference;
/**
* Background task to download tweet informations and to take actions
* @see TweetDetail
*
* @see TweetActivity
*/
public class TweetLoader extends AsyncTask<Long, Tweet, Tweet> {
@ -29,12 +30,12 @@ public class TweetLoader extends AsyncTask<Long, Tweet, Tweet> {
@Nullable
private EngineException twException;
private TwitterEngine mTwitter;
private WeakReference<TweetDetail> callback;
private WeakReference<TweetActivity> callback;
private AppDatabase db;
private final Action action;
public TweetLoader(TweetDetail callback, Action action) {
public TweetLoader(TweetActivity callback, Action action) {
mTwitter = TwitterEngine.getInstance(callback);
db = new AppDatabase(callback);
this.callback = new WeakReference<>(callback);

View File

@ -43,6 +43,9 @@ import static org.nuclearfog.twidda.backend.TwitterListLoader.Action.DELETE;
import static org.nuclearfog.twidda.backend.TwitterListLoader.Action.FOLLOW;
import static org.nuclearfog.twidda.backend.TwitterListLoader.Action.LOAD;
/**
* Fragment class for user lists
*/
public class ListFragment extends Fragment implements OnRefreshListener, ListClickListener {
public static final String KEY_FRAG_LIST_OWNER_ID = "list_owner_id";

View File

@ -22,7 +22,7 @@ import androidx.swiperefreshlayout.widget.SwipeRefreshLayout.OnRefreshListener;
import org.nuclearfog.twidda.R;
import org.nuclearfog.twidda.activity.MessagePopup;
import org.nuclearfog.twidda.activity.SearchPage;
import org.nuclearfog.twidda.activity.TweetDetail;
import org.nuclearfog.twidda.activity.TweetActivity;
import org.nuclearfog.twidda.activity.UserProfile;
import org.nuclearfog.twidda.adapter.MessageAdapter;
import org.nuclearfog.twidda.adapter.MessageAdapter.OnItemSelected;
@ -40,11 +40,14 @@ import static android.os.AsyncTask.Status.RUNNING;
import static android.widget.Toast.LENGTH_SHORT;
import static org.nuclearfog.twidda.activity.MessagePopup.KEY_DM_PREFIX;
import static org.nuclearfog.twidda.activity.SearchPage.KEY_SEARCH_QUERY;
import static org.nuclearfog.twidda.activity.TweetDetail.KEY_TWEET_ID;
import static org.nuclearfog.twidda.activity.TweetDetail.KEY_TWEET_NAME;
import static org.nuclearfog.twidda.activity.TweetDetail.LINK_PATTERN;
import static org.nuclearfog.twidda.activity.TweetActivity.KEY_TWEET_ID;
import static org.nuclearfog.twidda.activity.TweetActivity.KEY_TWEET_NAME;
import static org.nuclearfog.twidda.activity.TweetActivity.LINK_PATTERN;
import static org.nuclearfog.twidda.activity.UserProfile.KEY_PROFILE_ID;
/**
* Fragment class for direct message lists
*/
public class MessageFragment extends Fragment implements OnRefreshListener, OnItemSelected {
private MessageListLoader messageTask;
@ -117,7 +120,7 @@ public class MessageFragment extends Fragment implements OnRefreshListener, OnIt
if (LINK_PATTERN.matcher(shortLink).matches()) {
String name = shortLink.substring(20, shortLink.indexOf('/', 20));
long id = Long.parseLong(shortLink.substring(shortLink.lastIndexOf('/') + 1));
Intent intent = new Intent(getContext(), TweetDetail.class);
Intent intent = new Intent(getContext(), TweetActivity.class);
intent.putExtra(KEY_TWEET_ID, id);
intent.putExtra(KEY_TWEET_NAME, name);
startActivity(intent);

View File

@ -31,6 +31,9 @@ import static android.os.AsyncTask.Status.FINISHED;
import static android.os.AsyncTask.Status.RUNNING;
import static org.nuclearfog.twidda.activity.SearchPage.KEY_SEARCH_QUERY;
/**
* Fragment class for trend lists
*/
public class TrendFragment extends Fragment implements OnRefreshListener, TrendClickListener, FragmentChangeObserver {
private TrendListLoader trendTask;

View File

@ -15,7 +15,7 @@ import androidx.recyclerview.widget.RecyclerView;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout.OnRefreshListener;
import org.nuclearfog.twidda.activity.TweetDetail;
import org.nuclearfog.twidda.activity.TweetActivity;
import org.nuclearfog.twidda.adapter.FragmentAdapter.FragmentChangeObserver;
import org.nuclearfog.twidda.adapter.TweetAdapter;
import org.nuclearfog.twidda.adapter.TweetAdapter.TweetClickListener;
@ -30,8 +30,8 @@ import java.util.List;
import static android.os.AsyncTask.Status.FINISHED;
import static android.os.AsyncTask.Status.RUNNING;
import static org.nuclearfog.twidda.activity.TweetDetail.KEY_TWEET_ID;
import static org.nuclearfog.twidda.activity.TweetDetail.KEY_TWEET_NAME;
import static org.nuclearfog.twidda.activity.TweetActivity.KEY_TWEET_ID;
import static org.nuclearfog.twidda.activity.TweetActivity.KEY_TWEET_NAME;
public class TweetFragment extends Fragment implements OnRefreshListener, TweetClickListener, FragmentChangeObserver {
@ -121,7 +121,7 @@ public class TweetFragment extends Fragment implements OnRefreshListener, TweetC
if (getContext() != null && !reload.isRefreshing()) {
if (tweet.getEmbeddedTweet() != null)
tweet = tweet.getEmbeddedTweet();
Intent tweetIntent = new Intent(getContext(), TweetDetail.class);
Intent tweetIntent = new Intent(getContext(), TweetActivity.class);
tweetIntent.putExtra(KEY_TWEET_ID, tweet.getId());
tweetIntent.putExtra(KEY_TWEET_NAME, tweet.getUser().getScreenname());
startActivityForResult(tweetIntent, REQUEST_TWEET_CHANGED);

View File

@ -32,6 +32,9 @@ import static android.os.AsyncTask.Status.RUNNING;
import static org.nuclearfog.twidda.activity.UserProfile.KEY_PROFILE_ID;
import static org.nuclearfog.twidda.backend.UserListLoader.NO_CURSOR;
/**
* Fragment class for lists a list of users
*/
public class UserFragment extends Fragment implements OnRefreshListener, UserClickListener, FragmentChangeObserver {
public static final String KEY_FRAG_USER_MODE = "user_mode";