Skip to content

Commit

Permalink
Communities - built out structure
Browse files Browse the repository at this point in the history
  • Loading branch information
xFallingDuskx committed Aug 9, 2021
1 parent 488a2d0 commit 641d28d
Show file tree
Hide file tree
Showing 17 changed files with 974 additions and 39 deletions.
11 changes: 8 additions & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,21 @@
android:roundIcon="@drawable/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Platform">
<activity android:name=".activities.CommunitiesActivity_ByGenre"></activity>
<activity
android:name=".activities.CommunitiesActivity_Display"
android:label="@string/title_activity_communities_display"
android:theme="@style/Theme.Platform.NoActionBar" />
<activity android:name=".activities.SplashActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".activities.ChatsActivity_Messaging"
android:windowSoftInputMode="adjustPan"
/>
<activity
android:name=".activities.ChatsActivity_Messaging"
android:windowSoftInputMode="adjustPan" />
<activity android:name=".activities.CatalogActivity_TitleDisplay" />
<activity android:name=".activities.ProfileAboutActivity" />
<activity android:name=".activities.ProfileRecommendationsActivity" />
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/com/example/platform/ParseApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import android.app.Application;

import com.example.platform.models.Comment;
import com.example.platform.models.Community;
import com.example.platform.models.Conversation;
import com.example.platform.models.Episode;
import com.example.platform.models.Title;
Expand All @@ -22,6 +23,7 @@ public void onCreate() {
ParseObject.registerSubclass(Episode.class);
ParseObject.registerSubclass(Comment.class);
ParseObject.registerSubclass(Conversation.class);
ParseObject.registerSubclass(Community.class);

Parse.initialize(new Parse.Configuration.Builder(this)
.applicationId(getResources().getString(R.string.parseApplicationID))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package com.example.platform.activities;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.widget.RelativeLayout;

import com.example.platform.R;

public class CommunitiesActivity_ByGenre extends AppCompatActivity {

public static final String TAG = "CommunitiesActivity_ByGenre";
RelativeLayout rlAction, rlAdventure, rlAnimation, rlComedy, rlCrime, rlDocumentary, rlDrama, rlFamily, rlFantasy, rlHistory, rlHorror, rlMusic, rlReality, rlRomance, rlScienceFiction, rlSoap, rlTalk, rlThriller, rlWar, rlWestern;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_communities_by_genre);

rlAction = findViewById(R.id.rlAction_Genre);
rlAdventure = findViewById(R.id.rlAdventure_Genre);
rlAnimation = findViewById(R.id.rlAnimation_Genre);
rlComedy = findViewById(R.id.rlComedy_Genre);
rlCrime = findViewById(R.id.rlCrime_Genre);
rlDocumentary = findViewById(R.id.rlDocumentary_Genre);
rlDrama = findViewById(R.id.rlDrama_Genre);
rlFamily = findViewById(R.id.rlFamily_Genre);
rlFantasy = findViewById(R.id.rlFantasy_Genre);
rlHistory = findViewById(R.id.rlHistory_Genre);
rlHorror = findViewById(R.id.rlHorror_Genre);
rlMusic = findViewById(R.id.rlMusic_Genre);
rlReality = findViewById(R.id.rlReality_Genre);
rlRomance = findViewById(R.id.rlRomance_Genre);
rlScienceFiction = findViewById(R.id.rlScienceFiction_Genre);
rlSoap = findViewById(R.id.rlSoap_Genre);
rlTalk = findViewById(R.id.rlTalk_Genre);
rlThriller = findViewById(R.id.rlThriller_Genre);
rlWar = findViewById(R.id.rlWar_Genre);
rlWestern = findViewById(R.id.rlWestern_Genre);

//todo
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.example.platform.activities;

import android.os.Bundle;

import androidx.appcompat.app.AppCompatActivity;

import com.example.platform.R;

public class CommunitiesActivity_Display extends AppCompatActivity {

public static final String TAG = "CommunitiesActivity_Display";

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_communities_display);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,4 @@ public void onClick(View v) {
}
});
}

private void goMainActivity() {
Log.i(TAG, "Removing past activities from the stack to prevent user from going back");
Intent intent = new Intent(LaunchActivity.this, BaseActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}
}
Original file line number Diff line number Diff line change
@@ -1,45 +1,26 @@
package com.example.platform.fragments;

import android.content.Intent;
import android.os.Bundle;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.SearchView;
import androidx.appcompat.widget.Toolbar;
import androidx.core.view.MenuItemCompat;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.RelativeLayout;

import com.example.platform.R;
import com.example.platform.activities.ProfileActivity;
import com.example.platform.activities.SearchActivity;
import com.example.platform.adapters.GenreAdapter;
import com.example.platform.adapters.TitlesAdapter;
import com.example.platform.models.Genre;
import com.example.platform.models.SharedCatalogViewModel;
import com.example.platform.models.Title;

import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;
import java.util.List;
import java.util.TreeMap;

/**
* A simple {@link Fragment} subclass.
Expand All @@ -50,7 +31,6 @@ public class CatalogFragment_ByGenre extends Fragment {
public static final String TAG = "CatalogFragment_ByGenre";
private SharedCatalogViewModel sharedCatalogViewModel;
private RecyclerView rvListedGenres;
FragmentManager fragmentManager;
String mediaType;
List<Genre> allGenres;
GenreAdapter adapter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.RelativeLayout;

import com.example.platform.R;
import com.example.platform.activities.CommunitiesActivity_ByGenre;
import com.example.platform.activities.CommunitiesActivity_Display;
import com.example.platform.activities.ProfileActivity;

import org.jetbrains.annotations.NotNull;
Expand All @@ -33,6 +36,7 @@ public class CommunitiesFragment extends Fragment {

public static final String TAG = "CommunitiesFragment";
private ImageView ivProfile;
RelativeLayout rlAll, rlPopular, rlByGenres, rlUserCommunities;

public CommunitiesFragment() {
// Required empty public constructor
Expand Down Expand Up @@ -76,5 +80,44 @@ public void onClick(View v) {
startActivity(intent);
}
});

rlAll = view.findViewById(R.id.rlViewAll);
rlAll.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getContext(), CommunitiesActivity_Display.class);
intent.putExtra("tab", "all");
startActivity(intent);
}
});

rlPopular = view.findViewById(R.id.rlPopular);
rlPopular.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getContext(), CommunitiesActivity_Display.class);
intent.putExtra("tab", "popular");
startActivity(intent);
}
});

rlByGenres = view.findViewById(R.id.rlByGenres);
rlByGenres.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getContext(), CommunitiesActivity_ByGenre.class);
startActivity(intent);
}
});

rlUserCommunities = view.findViewById(R.id.rlUserCommunities);
rlUserCommunities.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getContext(), CommunitiesActivity_Display.class);
intent.putExtra("tab", "user");
startActivity(intent);
}
});
}
}
112 changes: 112 additions & 0 deletions app/src/main/java/com/example/platform/models/Community.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
package com.example.platform.models;

import com.parse.ParseClassName;
import com.parse.ParseObject;

import org.json.JSONArray;
import org.json.JSONException;

import java.util.ArrayList;
import java.util.List;

@ParseClassName("Community")
public class Community extends ParseObject {

public static final String TAG = "Community";
public static final String KEY_NAME = "name";
public static final String KEY_DESCRIPTION = "description";
public static final String KEY_CREATOR = "creator";
public static final String KEY_MEMBERS = "members";
public static final String KEY_GENRES = "genres";
public static final String KEY_KEYWORDS = "keywords";

public String name;
public String description;
public String creator;
public List<String> members;
public List<String> genres;
public List<String> keywords;

// Default, empty constructor
public Community() {}

public void setName(String name) {
put(Community.KEY_NAME, name);
}

public String getName() {
return getString(Community.KEY_NAME);
}

public void setDescription(String description) {
put(Community.KEY_DESCRIPTION, description);
}

public String getDescription() {
return getString(Community.KEY_DESCRIPTION);
}

public void setCreator(String creator) {
put(Community.KEY_CREATOR, creator);
}

public String getCreator() {
return getString(Community.KEY_CREATOR);
}

public void setMembers(List<String> members) {
put(Community.KEY_MEMBERS, members);
}

public List<String> getMembers() throws JSONException {
JSONArray jsonArray = getJSONArray(Community.KEY_MEMBERS);
List<String> members = new ArrayList<>();

if (jsonArray == null) {
return members;
} else {
for (int i = 0; i < jsonArray.length(); i++) {
members.add(jsonArray.getString(i));
}
return members;
}
}

public void setGenres(List<String> genres) {
put(Community.KEY_GENRES, genres);
this.genres = genres;
}

public List<String> getGenres() throws JSONException {
JSONArray jsonArray = getJSONArray(Community.KEY_GENRES);
List<String> genres = new ArrayList<>();

if (jsonArray == null) {
return genres;
} else {
for (int i = 0; i < jsonArray.length(); i++) {
genres.add(jsonArray.getString(i));
}
return genres;
}
}

public void setKeywords(List<String> keywords) {
put(Community.KEY_KEYWORDS, keywords);
this.keywords = keywords;
}

public List<String> getKeywords() throws JSONException {
JSONArray jsonArray = getJSONArray(Community.KEY_GENRES);
List<String> keywords = new ArrayList<>();

if (jsonArray == null) {
return keywords;
} else {
for (int i = 0; i < jsonArray.length(); i++) {
keywords.add(jsonArray.getString(i));
}
return keywords;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ public class Conversation extends ParseObject {
public String timestamp;
public Date updatedAtDate;

// Default, empty constructor
public Conversation() {}

public static String getCurrentTimetoken() {
long unixTime = System.currentTimeMillis() / 1000L;
long timetoken = unixTime * 10000000;
Expand Down
Loading

0 comments on commit 641d28d

Please sign in to comment.